Fail cleanly if SELinux disallows execmod for PE executables

Mike Hearn mike at navi.cx
Fri Jun 17 11:49:37 CDT 2005


Mike Hearn <mh at codeweavers.com>
Fail cleanly if SELinux disallows execmod for PE executables

Index: dlls/ntdll/loader.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/loader.c,v
retrieving revision 1.92
diff -u -p -d -u -r1.92 loader.c
--- dlls/ntdll/loader.c	17 Jun 2005 13:58:34 -0000	1.92
+++ dlls/ntdll/loader.c	17 Jun 2005 16:49:19 -0000
@@ -495,8 +495,12 @@ static WINE_MODREF *import_dll( HMODULE 
     while (import_list[protect_size].u1.Ordinal) protect_size++;
     protect_base = thunk_list;
     protect_size *= sizeof(*thunk_list);
-    NtProtectVirtualMemory( NtCurrentProcess(), &protect_base,
-                            &protect_size, PAGE_WRITECOPY, &protect_old );
+    if (NtProtectVirtualMemory( NtCurrentProcess(), &protect_base,
+                                &protect_size, PAGE_WRITECOPY, &protect_old ) != STATUS_SUCCESS)
+    {
+        ERR("cannot change IAT VM protection level, try disabling SELinux\n");
+        return NULL;
+    }
 
     imp_mod = wmImp->ldr.BaseAddress;
     exports = RtlImageDirectoryEntryToData( imp_mod, TRUE, IMAGE_DIRECTORY_ENTRY_EXPORT, &exp_size );
@@ -565,7 +569,11 @@ static WINE_MODREF *import_dll( HMODULE 
 
 done:
     /* restore old protection of the import address table */
-    NtProtectVirtualMemory( NtCurrentProcess(), &protect_base, &protect_size, protect_old, NULL );
+    if (NtProtectVirtualMemory( NtCurrentProcess(), &protect_base, &protect_size, protect_old, NULL ) != STATUS_SUCCESS)
+    {
+        ERR("cannot restore IAT protection after import, try disabling SELinux\n");
+    }
+    
     return wmImp;
 }
 



More information about the wine-patches mailing list