-
Notifications
You must be signed in to change notification settings - Fork 2
/
XFree86-elfloader-linux-non-exec-stack.patch
39 lines (39 loc) · 1.36 KB
/
XFree86-elfloader-linux-non-exec-stack.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
--- xc/programs/Xserver/hw/xfree86/loader/elfloader.c.orig 2007-04-09 17:37:17.000000000 +0200
+++ xc/programs/Xserver/hw/xfree86/loader/elfloader.c 2007-12-02 16:51:49.442062089 +0100
@@ -1165,7 +1165,7 @@
ErrorF("ELFCreateGOT() Unable to reallocate memory!!!!\n");
return FALSE;
}
-# if (defined(linux) && defined(__ia64__)) || \
+# if defined(linux) || \
defined(__OpenBSD__) || defined(__NetBSD__)
{
unsigned long page_size = getpagesize();
@@ -3483,10 +3483,16 @@
elffile->lsection[j].size = SecSize(i);
elffile->lsection[j].flags = flags;
switch (SecType(i)) {
-#if defined(__OpenBSD__) || defined(__NetBSD__)
+#if defined(linux) || defined(__OpenBSD__) || defined(__NetBSD__)
case SHT_PROGBITS:
- mprotect(elffile->lsection[j].saddr, SecSize(i),
+ {
+ unsigned long page_size = getpagesize();
+ unsigned long round;
+
+ round = (unsigned long)elffile->lsection[j].saddr & (page_size -1);
+ mprotect( (char*)elffile->lsection[j].saddr - round, SecSize(i) + round,
PROT_READ | PROT_WRITE | PROT_EXEC);
+ }
break;
#endif
case SHT_SYMTAB:
@@ -3688,7 +3694,7 @@
ErrorF("Unable to allocate ELF sections\n");
return NULL;
}
-# if (defined(linux) && defined(__ia64__)) || \
+# if defined(linux) || \
defined(__OpenBSD__) || defined(__NetBSD__)
{
unsigned long page_size = getpagesize();