Repository navigation
Fix mmap error handling to prevent misinterpreting error codes as valid addresses - #494
Merged
rennergade merged 17 commits intoNov 21, 2025
Conversation
ChinmayShringi
marked this pull request as ready for review
October 27, 2025 16:59
Fixes #451
Problem
The
libc::mmapfunction returns error codes in the same 64-bit value space as valid addresses. The existing code only checked for-1, which is insufficient and can lead to error codes being interpreted as valid addresses, causing crashes or incorrect behavior.Solution
Implemented proper error detection for
libc::mmapreturn values using two validation methods:-256 < ret < 0(cast to isize)This approach matches the error handling pattern used in
glibc/lind_syscall/lind_syscall.c.Changes
is_mmap_error()helper function infs_calls.rsfor centralized error detectionmmap_inner()to properly check both file-backed and anonymous mmap callsmunmap_inner()to detect mmap errors during memory protection resetmap_shm()inshared.rsfor shared memory operations