Message130008
$ 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. |
|
Date |
User |
Action |
Args |
2011-03-03 22:20:29 | neologix | set | recipients:
+ neologix |
2011-03-03 22:20:29 | neologix | set | messageid: <1299190829.31.0.825165631256.issue11391@psf.upfronthosting.co.za> |
2011-03-03 22:20:28 | neologix | link | issue11391 messages |
2011-03-03 22:20:28 | neologix | create | |
|