source:
patches/grub-0.97-use_mmap-1.patch@
2a5f085
Last change on this file since 2a5f085 was 8f78e14, checked in by , 18 years ago | |
---|---|
|
|
File size: 2.0 KB |
-
grub/asmstub.c
Submitted By: Jim Gifford <jim@linuxfromscratch.org> Date: 07-14-2006 Initial Package Version: 0.97 Upstream Status: Unknown Origin: Grub Bug Report - http://savannah.gnu.org/bugs/?func=detailitem&item_id=11312 Description: This patch fixes the following issues on x86_64 1) malloc'd pages seem to lack the execute bit on x86_64; 2) grub seems to use some stack pointer diversion to malloc'd pages; 3) nested functions execute data on the stack; 4) this causes a segfault (at least on my machine) diff -Naur grub-0.97.orig/grub/asmstub.c grub-0.97/grub/asmstub.c
old new 43 43 #include <termios.h> 44 44 #include <signal.h> 45 45 46 #include <sys/mman.h> 47 46 48 #ifdef __linux__ 47 49 # include <sys/ioctl.h> /* ioctl */ 48 50 # if !defined(__GLIBC__) || \ … … 142 144 } 143 145 144 146 assert (grub_scratch_mem == 0); 145 scratch = malloc (0x100000 + EXTENDED_MEMSIZE + 15); 147 scratch = mmap(NULL, 148 0x100000 + EXTENDED_MEMSIZE + 15, 149 PROT_EXEC | PROT_READ | PROT_WRITE, 150 MAP_PRIVATE | MAP_GROWSDOWN | MAP_ANONYMOUS | MAP_32BIT, 151 -1, 152 0); 153 146 154 assert (scratch); 147 155 grub_scratch_mem = (char *) ((((int) scratch) >> 4) << 4); 148 156 149 157 /* FIXME: simulate the memory holes using mprot, if available. */ 150 158 151 159 assert (disks == 0); 152 disks = malloc (NUM_DISKS * sizeof (*disks)); 160 disks = mmap(NULL, 161 NUM_DISKS * sizeof (*disks), 162 PROT_EXEC | PROT_READ | PROT_WRITE, 163 MAP_PRIVATE | MAP_GROWSDOWN | MAP_ANONYMOUS | MAP_32BIT, 164 -1, 165 0); 153 166 assert (disks); 154 167 /* Initialize DISKS. */ 155 168 for (i = 0; i < NUM_DISKS; i++) … … 215 228 /* Release memory. */ 216 229 restore_device_map (device_map); 217 230 device_map = 0; 218 free (disks);231 munmap(disks, NUM_DISKS * sizeof (*disks)); 219 232 disks = 0; 220 free (scratch);233 munmap(scratch, 0x100000 + EXTENDED_MEMSIZE + 15); 221 234 grub_scratch_mem = 0; 222 235 223 236 if (serial_device)
Note:
See TracBrowser
for help on using the repository browser.