Skip to content

[kernel] Fix AF_UNIX kernel overwrite from sun_path[sockaddr_len]#2661

Merged
ghaerr merged 1 commit intomasterfrom
sun_path
Apr 26, 2026
Merged

[kernel] Fix AF_UNIX kernel overwrite from sun_path[sockaddr_len]#2661
ghaerr merged 1 commit intomasterfrom
sun_path

Conversation

@ghaerr
Copy link
Copy Markdown
Owner

@ghaerr ghaerr commented Apr 26, 2026

Fixes an internal socket structure overwrite when passing an AF_UNIX sockaddr_un struct with length > 20. Found by ChatGTP in #2646.

@Vutshi, thank you for running the AI kernel audit. I wrestled with this particular problem a couple times thinking I had finally fixed it, but never realized the big problem was that the passed sockaddr_len was indexing a non-zero offset of sun_path within the sockaddr_un struct. This should finally fix the memory corruption errors I had been seeing but didn't actually finally fix.

The ChatGPT proposed fix also includes a bit more argument validation as well.

Tested by running Nano-X, which uses UNIX named pipes, which exercises this code. To keep the task structure small, the max string length of named pipes (UNIX_PATH_MAX) remains at 20 including NUL (e.g. /tmp/nxsock), but is now more firmly checked and corruption potential removed.

Currently unused regression tests included in elkscmd/test/syscall/.

Thank you!

@ghaerr ghaerr merged commit c872533 into master Apr 26, 2026
1 check passed
@ghaerr ghaerr deleted the sun_path branch April 26, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant