New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mmap write segfaults if PROT_WRITE bit is not set in prot #55600
Comments
$ 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. |
Patch looks mostly good. Why do you use ~PROT_WRITE instead of PROT_READ|PROT_EXEC as in your example? |
Because I'm not sure that PROT_EXEC is supported by all platforms. See
Me neither. I'd guess that the syscall just performs bitwise AND to |
Following error on the OpenIndiana buildbot: test test_mmap failed -- Traceback (most recent call last):
File "/export/home/buildbot/32bits/3.1.cea-indiana-x86/build/Lib/test/test_mmap.py", line 242, in test_access_parameter
m = mmap.mmap(f.fileno(), mapsize, prot=~mmap.PROT_WRITE)
mmap.error: [Errno 13] Permission denied |
Buildbot failure should be fixed in e3eaf7dbb2b4. |
Merged in 92ab79ca4eeb, f9f9662dfb1f, 2e4468841c4c. Thank you! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: