12345678910111213141516171819202122232425262728293031323334 |
- $OpenBSD: patch-code_qcommon_vm_x86_c,v 1.1 2012/03/18 16:48:16 kirby Exp $
- * Add PROT_READ to x86 and x86_64 VM mmap calls[1]
- [1] According to OpenBSD's mmap(2):
- BUGS
- Due to a limitation of the current vm system (see uvm(9)), mapping
- descriptors PROT_WRITE without also specifying PROT_READ is useless
- (results in a segmentation fault when first accessing the mapping). This
- means that such descriptors must be opened with O_RDWR, which requires
- both read and write permissions on the underlying object.
- --- code/qcommon/vm_x86.c.orig Sat Dec 24 14:29:32 2011
- +++ code/qcommon/vm_x86.c Sun Mar 11 15:22:08 2012
- @@ -36,7 +36,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
-
- /* need this on NX enabled systems (i386 with PAE kernel or
- * noexec32=on x86_64) */
- -#if defined(__linux__) || defined(__FreeBSD__)
- +#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
- #define VM_X86_MMAP
- #endif
-
- @@ -1094,7 +1094,7 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
- // copy to an exact size buffer on the hunk
- vm->codeLength = compiledOfs;
- #ifdef VM_X86_MMAP
- - vm->codeBase = mmap(NULL, compiledOfs, PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0);
- + vm->codeBase = mmap(NULL, compiledOfs, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0);
- if(vm->codeBase == MAP_FAILED)
- Com_Error(ERR_FATAL, "VM_CompileX86: can't mmap memory");
- #elif _WIN32
|