Commit Graph
7 Commits
Author SHA1 Message Date
slopgobblercobbler 7239ebb63e fix(libkernel): validate address family against socket family in bind 2026-10-25 02:14:14 +01:00
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
Dean 7956a166c7 Merge pull request #9108 from Retr0G28/fix/socket-address-length-exact
fix(libkernel): reject socket addresses longer than sockaddr_in or sockaddr_in6 with EINVAL
2026-10-24 09:12:39 +13:00
Retr0 f2bc1195f8 fix(libkernel): reject socket addresses longer than sockaddr_in or sockaddr_in6 with EINVAL
FreeBSD 11.4 getsockaddr sets sa_len to the length argument, and
tcp_usr_bind, tcp_usr_connect, in_pcbbind_setup, in_pcbconnect_setup,
in6_pcbbind and in6_pcbladdr answer EINVAL when it is not the size of
the socket family's address. udp6_bind and udp6_connect pass an
IPv4-mapped address to the IPv4 code without that check when
IPV6_V6ONLY is clear, and udp6_send always checks it. bind and connect
on AF_INET and AF_INET6 sockets, and sendto on AF_INET6 datagram
sockets, now fail a longer address with EINVAL.
2026-10-21 15:31:15 +03:00
xXPBSXxandClaude Sonnet 5.5 ce8f7803ea fix(libkernel): check socket address arguments before the descriptor
bind, connect and sendto looked the descriptor up before they looked at the
address length, so a descriptor that is not open hid an argument error.
FreeBSD 11.4 sys_bind, sys_connect and sendit run getsockaddr first
(ENAMETOOLONG, EINVAL, EFAULT) and only then look the descriptor up, so
these arguments are now answered first and EBADF only follows for a valid
address.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-20 14:43:54 +02:00
xXPBSXxandClaude Sonnet 5.5 a957b8c106 test(libkernel): check and close the IPv6 socket of guest_socket_address_length
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-20 02:30:55 +02:00
xXPBSXxandClaude Sonnet 5.5 cd09badb2b fix(libkernel): fail a short or long socket address like FreeBSD
bind, connect and sendto answered EFAULT for an address length below 2 and EAFNOSUPPORT for an AF_INET address below 16 or an AF_INET6 address below 28 bytes. FreeBSD 11.4's getsockaddr fails a length below 2 with EINVAL and above SOCK_MAXADDRLEN (255) with ENAMETOOLONG, and the protocols compare the length with sizeof(struct sockaddr_in) or sockaddr_in6 and fail with EINVAL.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-20 02:30:55 +02:00