This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author neologix
Recipients neologix
Date 2011-03-03.22:20:28
SpamBayes Score 2.2219449e-12
Marked as misclassified No
Message-id <1299190829.31.0.825165631256.issue11391@psf.upfronthosting.co.za>
In-reply-to
Content
$ cat /tmp/test_mmap.py 
import mmap

m = mmap.mmap(-1, 1024, prot=mmap.PROT_READ|mmap.PROT_EXEC)
m[0] = 0
$ ./python /tmp/test_mmap.py 
Segmentation fault

When trying to perform a write, is_writable is called to check that we can indeed write to the mmaped area. is_writable just checks the access mode, and if it's not ACCESS_READ, we go ahead and proceed to the write.
The problem is that under Unix, it's possible to pass ACCESS_DEFAULT, and in that case no check is done on prot value.
In that case, is_writable will return true (since ACCESS_DEFAULT != ACCESS_READ), but if prot doesn't include PROT_WRITE bit, we'll segfault.
Attached is a patch including fix and specific test.
History
Date User Action Args
2011-03-03 22:20:29neologixsetrecipients: + neologix
2011-03-03 22:20:29neologixsetmessageid: <1299190829.31.0.825165631256.issue11391@psf.upfronthosting.co.za>
2011-03-03 22:20:28neologixlinkissue11391 messages
2011-03-03 22:20:28neologixcreate