Map the VRAM and Video ROM/System ROM seperately.
authorMichał Januszewski <spock@gentoo.org>
Sun, 7 Sep 2008 23:35:30 +0000 (8 01:35 +0200)
committerMichał Januszewski <spock@gentoo.org>
Sun, 7 Sep 2008 23:35:30 +0000 (8 01:35 +0200)
lrmi maps both the Video RAM and ROM with PROT_EXEC.  This can cause
problems on systems with NX and PaX.  In order to avoid these, map
the RAM and ROM areas separately, with different PROT_* flags.

libs/lrmi-0.10/lrmi.c

index c68d753..de75e75 100644 (file)
@@ -347,14 +347,23 @@ LRMI_init(void)
                return 0;
        }
 
-       if (!map_file((void *)0xa0000, 0x100000 - 0xa0000,
-        PROT_READ | PROT_WRITE | PROT_EXEC,
+       if (!map_file((void *)0xa0000, 0x20000,
+        PROT_READ | PROT_WRITE,
         MAP_FIXED | MAP_SHARED, "/dev/mem", 0xa0000)) {
                munmap((void *)0, 0x502);
                real_mem_deinit();
                return 0;
        }
 
+       if (!map_file((void *)0xc0000, 0x30000,
+               PROT_READ | PROT_WRITE | PROT_EXEC,
+               MAP_FIXED | MAP_SHARED, "/dev/mem", 0xc0000)) {
+               munmap((void *)0, 0x502);
+               munmap((void *)0xa0000, 0x20000);
+               real_mem_deinit();
+               return 0;
+       }
+
        /*
         Allocate a stack
        */