[PATCH] ntdll/tests: Skip the map protect tests if we can't disable no-exec.

Huw Davies huw at codeweavers.com
Mon Jul 9 05:12:56 CDT 2018


Signed-off-by: Huw Davies <huw at codeweavers.com>
---
When run as a stand-alone test most of the testbot VMs have
the process execute flags bits MAP_EXECUTE_OPTION_DISBABLE and
MAP_EXECUTE_OPTION_PERMANENT set.  With the permanent bit set,
it's not possible to turn off no-exec.  It's unclear why, when
run as part of winetest, this is not the case.

Also note that this test doesn't run on 64-bit, as apparently
the process execute flags are not supported on that platform.


 dlls/ntdll/tests/info.c | 32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c
index 4a2d9e6933..7d60b94f15 100644
--- a/dlls/ntdll/tests/info.c
+++ b/dlls/ntdll/tests/info.c
@@ -1776,20 +1776,30 @@ static void test_mapprotection(void)
     NTSTATUS status;
     SIZE_T retlen, count;
     void (*f)(void);
+    BOOL reset_flags = FALSE;
 
-    if (!pNtClose) {
-        skip("No NtClose ... Win98\n");
-        return;
-    }
     /* Switch to being a noexec unaware process */
     status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessExecuteFlags, &oldflags, sizeof (oldflags), &flagsize);
-    if (status == STATUS_INVALID_PARAMETER) {
-        skip("Invalid Parameter on ProcessExecuteFlags query?\n");
+    if (status == STATUS_INVALID_PARAMETER)
+    {
+        skip("Unable to query process execute flags on this platform\n");
         return;
     }
-    ok( (status == STATUS_SUCCESS) || (status == STATUS_INVALID_INFO_CLASS), "Expected STATUS_SUCCESS, got %08x\n", status);
-    status = pNtSetInformationProcess( GetCurrentProcess(), ProcessExecuteFlags, &flags, sizeof(flags) );
-    ok( (status == STATUS_SUCCESS) || (status == STATUS_INVALID_INFO_CLASS), "Expected STATUS_SUCCESS, got %08x\n", status);
+    ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status );
+    trace("Process execute flags %08x\n", oldflags);
+
+    if (oldflags & MEM_EXECUTE_OPTION_DISABLE)
+    {
+        if (oldflags & MEM_EXECUTE_OPTION_PERMANENT)
+        {
+            skip("Unable to turn off noexec\n");
+            return;
+        }
+
+        status = pNtSetInformationProcess( GetCurrentProcess(), ProcessExecuteFlags, &flags, sizeof(flags) );
+        ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status );
+        reset_flags = TRUE;
+    }
 
     size.u.LowPart  = 0x2000;
     size.u.HighPart = 0;
@@ -1832,8 +1842,8 @@ static void test_mapprotection(void)
     ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
     pNtClose (h);
 
-    /* Switch back */
-    pNtSetInformationProcess( GetCurrentProcess(), ProcessExecuteFlags, &oldflags, sizeof(oldflags) );
+    if (reset_flags)
+        pNtSetInformationProcess( GetCurrentProcess(), ProcessExecuteFlags, &oldflags, sizeof(oldflags) );
 }
 
 static void test_queryvirtualmemory(void)
-- 
2.16.2




More information about the wine-devel mailing list