diff options
author | dyson <dyson@FreeBSD.org> | 1996-12-30 05:31:21 +0000 |
---|---|---|
committer | dyson <dyson@FreeBSD.org> | 1996-12-30 05:31:21 +0000 |
commit | c232302d3fb7bc2db6053e608cf8843199fea7c1 (patch) | |
tree | 897f659fee68ca11a992ee3be71d600f4e9207dc /sys | |
parent | a61ba0575d63937c042107bda370e8c8590d6120 (diff) | |
download | FreeBSD-src-c232302d3fb7bc2db6053e608cf8843199fea7c1.zip FreeBSD-src-c232302d3fb7bc2db6053e608cf8843199fea7c1.tar.gz |
Let the VM system know that on certain arch's that VM_PROT_READ
also implies VM_PROT_EXEC. We support it that way for now,
since the break system call by default gives VM_PROT_ALL. Now
we have a better chance of coalesing map entries when mixing
mmap/break type operations. This was contributing to excessive
numbers of map entries on the modula-3 runtime system. The
problem is still not "solved", but the situation makes more
sense.
Eventually, when we work on architectures where VM_PROT_READ
is orthogonal to VM_PROT_EXEC, we will have to visit this
issue carefully (esp. regarding security issues.)
Diffstat (limited to 'sys')
-rw-r--r-- | sys/amd64/include/vmparam.h | 4 | ||||
-rw-r--r-- | sys/i386/include/vmparam.h | 4 | ||||
-rw-r--r-- | sys/vm/vm_mmap.c | 14 |
3 files changed, 19 insertions, 3 deletions
diff --git a/sys/amd64/include/vmparam.h b/sys/amd64/include/vmparam.h index 48b570d..5c3774e 100644 --- a/sys/amd64/include/vmparam.h +++ b/sys/amd64/include/vmparam.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91 - * $Id: vmparam.h,v 1.20 1996/04/30 12:02:12 phk Exp $ + * $Id: vmparam.h,v 1.21 1996/05/02 14:20:07 phk Exp $ */ @@ -47,6 +47,8 @@ * Machine dependent constants for 386. */ +#define VM_PROT_READ_IS_EXEC /* if you can read -- then you can exec */ + /* * Virtual memory related constants, all in bytes */ diff --git a/sys/i386/include/vmparam.h b/sys/i386/include/vmparam.h index 48b570d..5c3774e 100644 --- a/sys/i386/include/vmparam.h +++ b/sys/i386/include/vmparam.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91 - * $Id: vmparam.h,v 1.20 1996/04/30 12:02:12 phk Exp $ + * $Id: vmparam.h,v 1.21 1996/05/02 14:20:07 phk Exp $ */ @@ -47,6 +47,8 @@ * Machine dependent constants for 386. */ +#define VM_PROT_READ_IS_EXEC /* if you can read -- then you can exec */ + /* * Virtual memory related constants, all in bytes */ diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 3d89951..abd6ff6 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -38,7 +38,7 @@ * from: Utah $Hdr: vm_mmap.c 1.6 91/10/21$ * * @(#)vm_mmap.c 8.4 (Berkeley) 1/12/94 - * $Id: vm_mmap.c,v 1.55 1996/12/22 23:17:09 joerg Exp $ + * $Id: vm_mmap.c,v 1.56 1996/12/28 22:40:44 dyson Exp $ */ /* @@ -475,6 +475,10 @@ mprotect(p, uap, retval) addr = (vm_offset_t) uap->addr; size = uap->len; prot = uap->prot & VM_PROT_ALL; +#if defined(VM_PROT_READ_IS_EXEC) + if (prot & VM_PROT_READ) + prot |= VM_PROT_EXECUTE; +#endif pageoff = (addr & PAGE_MASK); addr -= pageoff; @@ -927,6 +931,14 @@ vm_mmap(map, addr, size, prot, maxprot, flags, handle, foff) docow = MAP_COPY_ON_WRITE | MAP_COPY_NEEDED; } +#if defined(VM_PROT_READ_IS_EXEC) + if (prot & VM_PROT_READ) + prot |= VM_PROT_EXECUTE; + + if (maxprot & VM_PROT_READ) + maxprot |= VM_PROT_EXECUTE; +#endif + rv = vm_map_find(map, object, foff, addr, size, fitit, prot, maxprot, docow); |