Cygwin: drop Vista WOW64 specific child process handle bug

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2021-10-29 14:52:58 +02:00
parent 7a3df8bb6f
commit e36811afb4
4 changed files with 5 additions and 39 deletions

View File

@ -52,7 +52,7 @@ struct cchildren
class child_info
{
public:
DWORD msv_count; // set to pseudo-count on Vista WOW64, zeroed otherwise
DWORD msv_count; // set to 0
DWORD cb; // size of this record
DWORD intro; // improbable string
DWORD magic; // magic number unique to child_info

View File

@ -809,31 +809,11 @@ int child_info::retry_count = 0;
by fork/spawn/exec. */
child_info::child_info (unsigned in_cb, child_info_types chtype,
bool need_subproc_ready):
cb (in_cb), intro (PROC_MAGIC_GENERIC), magic (CHILD_INFO_MAGIC),
type (chtype), cygheap (::cygheap), cygheap_max (::cygheap_max),
flag (0), retry (child_info::retry_count), rd_proc_pipe (NULL),
wr_proc_pipe (NULL)
msv_count (0), cb (in_cb), intro (PROC_MAGIC_GENERIC),
magic (CHILD_INFO_MAGIC), type (chtype), cygheap (::cygheap),
cygheap_max (::cygheap_max), flag (0), retry (child_info::retry_count),
rd_proc_pipe (NULL), wr_proc_pipe (NULL)
{
/* It appears that when running under WOW64 on Vista 64, the first DWORD
value in the datastructure lpReserved2 is pointing to (msv_count in
Cygwin), has to reflect the size of that datastructure as used in the
Microsoft C runtime (a count value, counting the number of elements in
two subsequent arrays, BYTE[count and HANDLE[count]), even though the C
runtime isn't used. Otherwise, if msv_count is 0 or too small, the
datastructure gets overwritten.
This seems to be a bug in Vista's WOW64, which apparently copies the
lpReserved2 datastructure not using the cbReserved2 size information,
but using the information given in the first DWORD within lpReserved2
instead. However, it's not clear if a non-0 count doesn't result in
trying to evaluate the content, so we do this really only for Vista 64.
The value is sizeof (child_info_*) / 5 which results in a count which
covers the full datastructure, plus not more than 4 extra bytes. This
is ok as long as the child_info structure is cosily stored within a bigger
datastructure. */
msv_count = wincap.needs_count_in_si_lpres2 () ? in_cb / 5 : 0;
fhandler_union_cb = sizeof (fhandler_union);
user_h = cygwin_user_h;
if (strace.active ())

View File

@ -23,7 +23,6 @@ wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
mmap_storage_high:0x070000000000LL,
{
is_server:false,
needs_count_in_si_lpres2:true,
needs_query_information:true,
has_gaa_largeaddress_bug:true,
has_broken_alloc_console:false,
@ -59,7 +58,6 @@ wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = {
mmap_storage_high:0x070000000000LL,
{
is_server:false,
needs_count_in_si_lpres2:false,
needs_query_information:true,
has_gaa_largeaddress_bug:true,
has_broken_alloc_console:true,
@ -95,7 +93,6 @@ wincaps wincap_8 __attribute__((section (".cygwin_dll_common"), shared)) = {
mmap_storage_high:0x070000000000LL,
{
is_server:false,
needs_count_in_si_lpres2:false,
needs_query_information:true,
has_gaa_largeaddress_bug:false,
has_broken_alloc_console:true,
@ -131,7 +128,6 @@ wincaps wincap_8_1 __attribute__((section (".cygwin_dll_common"), shared)) = {
mmap_storage_high:0x700000000000LL,
{
is_server:false,
needs_count_in_si_lpres2:false,
needs_query_information:false,
has_gaa_largeaddress_bug:false,
has_broken_alloc_console:true,
@ -167,7 +163,6 @@ wincaps wincap_10_1507 __attribute__((section (".cygwin_dll_common"), shared))
mmap_storage_high:0x700000000000LL,
{
is_server:false,
needs_count_in_si_lpres2:false,
needs_query_information:false,
has_gaa_largeaddress_bug:false,
has_broken_alloc_console:true,
@ -203,7 +198,6 @@ wincaps wincap_10_1607 __attribute__((section (".cygwin_dll_common"), shared))
mmap_storage_high:0x700000000000LL,
{
is_server:false,
needs_count_in_si_lpres2:false,
needs_query_information:false,
has_gaa_largeaddress_bug:false,
has_broken_alloc_console:true,
@ -239,7 +233,6 @@ wincaps wincap_10_1703 __attribute__((section (".cygwin_dll_common"), shared)) =
mmap_storage_high:0x700000000000LL,
{
is_server:false,
needs_count_in_si_lpres2:false,
needs_query_information:false,
has_gaa_largeaddress_bug:false,
has_broken_alloc_console:true,
@ -275,7 +268,6 @@ wincaps wincap_10_1709 __attribute__((section (".cygwin_dll_common"), shared)) =
mmap_storage_high:0x700000000000LL,
{
is_server:false,
needs_count_in_si_lpres2:false,
needs_query_information:false,
has_gaa_largeaddress_bug:false,
has_broken_alloc_console:true,
@ -311,7 +303,6 @@ wincaps wincap_10_1803 __attribute__((section (".cygwin_dll_common"), shared)) =
mmap_storage_high:0x700000000000LL,
{
is_server:false,
needs_count_in_si_lpres2:false,
needs_query_information:false,
has_gaa_largeaddress_bug:false,
has_broken_alloc_console:true,
@ -347,7 +338,6 @@ wincaps wincap_10_1809 __attribute__((section (".cygwin_dll_common"), shared)) =
mmap_storage_high:0x700000000000LL,
{
is_server:false,
needs_count_in_si_lpres2:false,
needs_query_information:false,
has_gaa_largeaddress_bug:false,
has_broken_alloc_console:true,
@ -383,7 +373,6 @@ wincaps wincap_10_1903 __attribute__((section (".cygwin_dll_common"), shared)) =
mmap_storage_high:0x700000000000LL,
{
is_server:false,
needs_count_in_si_lpres2:false,
needs_query_information:false,
has_gaa_largeaddress_bug:false,
has_broken_alloc_console:true,
@ -482,7 +471,6 @@ wincapc::init ()
&& !wow64)
#endif
{
((wincaps *)caps)->needs_count_in_si_lpres2 = false;
((wincaps *)caps)->has_gaa_largeaddress_bug = false;
((wincaps *)caps)->has_broken_prefetchvm = false;
((wincaps *)caps)->no_msv1_0_s4u_logon_in_wow64 = false;

View File

@ -17,7 +17,6 @@ struct wincaps
ops generated by gcc are off by 4 bytes. */
struct __attribute__ ((aligned (8))) {
unsigned is_server : 1;
unsigned needs_count_in_si_lpres2 : 1;
unsigned needs_query_information : 1;
unsigned has_gaa_largeaddress_bug : 1;
unsigned has_broken_alloc_console : 1;
@ -85,7 +84,6 @@ public:
intptr_t IMPLEMENT (mmap_storage_high)
#endif
bool IMPLEMENT (is_server)
bool IMPLEMENT (needs_count_in_si_lpres2)
bool IMPLEMENT (needs_query_information)
bool IMPLEMENT (has_gaa_largeaddress_bug)
bool IMPLEMENT (has_broken_alloc_console)