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
This commit is contained in:
Alan Cox 2000-03-10 09:11:24 +00:00
parent 643b70ec9d
commit af25d10c91

View File

@ -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;