libkernel: setsockopt/getsockopt with an unknown level fails with ENOPROTOOPT where FreeBSD 11.4 fails with EINVAL #8447
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T12:46:54Z.
Repro
Any host.
s = socket(AF_INET, SOCK_STREAM, 0), thensetsockopt(s, 999, 1, &one, 4)orgetsockopt(s, 999, 1, &v, &len).Expected (FreeBSD 11.4): EINVAL (22).
sosetopt/sogetoptpass a level other than SOL_SOCKET to the protocol;tcp_ctloutputforwards a level other than IPPROTO_TCP toip_ctloutput(sys/netinet/ip_output.c:943-944), which answersEINVALfor every level but IPPROTO_IP. The same holds forip6_ctloutput(sys/netinet6/ip6_output.c:1459) on an AF_INET6 socket and foruipc_ctloutput(sys/kern/uipc_usrreq.c:1228-1229) on an AF_UNIX socket.Actual: ENOPROTOOPT (42), from
if (level != 0xffff && level != 6 && level != 41) return Fail(42)insetsockopt_nid_postfixandgetsockopt_nid_postfix.Test:
core/libs/tests/GuestSocketOptions.cpp(new caseUnknownLevelsFollowFreeBsd; fails with errno 42 before the fix).Fix branch: https://github.com/xXPBSXx/AnyPS5/tree/fix/sockopt-unknown-level-einval
AI-assisted (Claude Code).