Commit Graph
3 Commits
Author SHA1 Message Date
bernardandClaude Code 9e29e3246b [components][lwp] harden sys_getaddrinfo user pointer handling
sys_getaddrinfo() validated the top-level res buffer, then wrote the
resolved socket address through res->ai_addr, a user-controlled nested
pointer that was never checked. On Smart/MMU builds a user program could
therefore turn getaddrinfo() into an arbitrary kernel write. The hints
fields were also read directly from user memory after the access check,
leaving a TOCTOU window.

Copy res and hints into kernel temporaries with lwp_get_from_user() so
all nested pointers come from one validated snapshot. Write the nested
sockaddr and the outer addrinfo back with lwp_put_to_user(), which
validates the destination range and never dereferences an unchecked user
pointer in kernel context.

Also fix the servname copy check (a size_t result can never be < 0),
allocate the kernel addrinfo with sizeof(*k_hints), and release k_res on
the new error paths.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-03 09:04:56 +08:00
bernard 6b287856f9 [components][lwp] apply clang-format to syscall sources
- format the newly split syscall implementation files
- no functional change
2026-10-29 14:50:07 +08:00
bernard 68757abdcc [components][lwp] split syscall implementation by subsystem
- move syscall implementations from lwp_syscall.c into syscall/
- group memory, file, socket, process, IPC and time syscalls
- add a shared syscall dispatch table and internal header
- register the new directory from the LWP build script
- no functional change
2026-10-29 14:50:07 +08:00