From af25d10c9123a8e32d87a41ad7795df0088a5e60 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Fri, 10 Mar 2000 09:11:24 +0000 Subject: [PATCH] shmat: If VM_PROT_READ_IS_EXEC is defined and prot includes VM_PROT_READ, VM_PROT_EXECUTE must be added to prot before calling vm_map_find. Without this change, an mprotect on a shmat'ed region fails (when it shouldn't). This bug was reported Feb 28 by Brooks Davis on -hackers. Reviewed by: bde Approved by: jkh --- sys/kern/sysv_shm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/kern/sysv_shm.c b/sys/kern/sysv_shm.c index 6fcfdf23e28a..866a6ce6505c 100644 --- a/sys/kern/sysv_shm.c +++ b/sys/kern/sysv_shm.c @@ -249,7 +249,11 @@ shmat(p, uap) if (i >= shminfo.shmseg) return EMFILE; size = round_page(shmseg->shm_segsz); +#ifdef VM_PROT_READ_IS_EXEC + prot = VM_PROT_READ | VM_PROT_EXECUTE; +#else prot = VM_PROT_READ; +#endif if ((uap->shmflg & SHM_RDONLY) == 0) prot |= VM_PROT_WRITE; flags = MAP_ANON | MAP_SHARED;