[libc-commits] [libc] [libc] check a few syscall #'s to avoid wrong syscalls (PR #123100)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Fri Jan 17 08:50:17 PST 2025
nickdesaulniers wrote:
I've been thinking more about how do we better catch the case of:
```c
long mmap_ret_val = syscall_impl<long>(MMAP_SYSCALL_NUMBER, nullptr,
alloc_size, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
if (mmap_ret_val < 0 && static_cast<uintptr_t>(mmap_ret_val) > -app.page_size)
syscall_impl<long>(SYS_exit, 1);
```
when `MMAP_SYSCALL_NUMBER` and `SYS_exit` are both wrong (for the wrong architecture). I think maybe we could have an internal helper function marked `[[noreturn]]` that checks the return value from the syscall to exit and traps. That said, perhaps it's possible to have the wrong syscall to exit succeed, so we'd have a false positive there...
https://github.com/llvm/llvm-project/pull/123100
More information about the libc-commits
mailing list