|author||Rich Felker <email@example.com>||2012-12-20 12:16:02 -0500|
|committer||Rich Felker <firstname.lastname@example.org>||2012-12-20 12:16:02 -0500|
clean up and fix logic for making mmap fail on invalid/unsupported offsets
the previous logic was assuming the kernel would give EINVAL when passed an invalid address, but instead with MAP_FIXED it was giving EPERM, as it considered this an attempt to map over kernel memory. instead of trying to get the kernel to do the rigth thing, the new code just handles the error in userspace. I have also cleaned up the code to use a single mask to check for invalid low bits and unsupported high bits, so it's simpler and more clearly correct. the old code was actually wrong for sizeof(long) smaller than sizeof(off_t) but not equal to 4; now it should be correct for all possibilities. for 64-bit systems, the low-bits test is new and extraneous (the kernel should catch the error anyway when the mmap2 syscall is not used), but it's cheap anyway. if this is an issue, the OFF_MASK definition could be tweaked to omit the low bits when SYS_mmap2 is not defined.
Diffstat (limited to 'src/env')
0 files changed, 0 insertions, 0 deletions