summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2000-03-10 09:11:24 +0000
committeralc <alc@FreeBSD.org>2000-03-10 09:11:24 +0000
commitedd69da639130f0e97e6d966fa0372ef8320e599 (patch)
treea8a570a9a213d16ae4e1e4700ab2c42d32d910f0 /sys
parent3b59707eecfa5a59ebd523af8f14198ec2fa0551 (diff)
downloadFreeBSD-src-edd69da639130f0e97e6d966fa0372ef8320e599.zip
FreeBSD-src-edd69da639130f0e97e6d966fa0372ef8320e599.tar.gz
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 <brooks@one-eyed-alien.net> on -hackers. Reviewed by: bde Approved by: jkh
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/sysv_shm.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/kern/sysv_shm.c b/sys/kern/sysv_shm.c
index 6fcfdf2..866a6ce 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;
OpenPOWER on IntegriCloud