]> git.ipfire.org Git - thirdparty/linux.git/commit
landlock: Fix TCP handling of short AF_UNSPEC addresses
authorMatthieu Buffet <matthieu@buffet.re>
Mon, 27 Oct 2025 19:07:26 +0000 (20:07 +0100)
committerMickaël Salaün <mic@digikod.net>
Fri, 26 Dec 2025 19:38:56 +0000 (20:38 +0100)
commite4d82cbce2258f454634307fdabf33aa46b61ab0
treedeca7cd4c887f8672fde80d9f9821b2d44e02e63
parent552dbf47a85c3b0eea1d7984ce3794b8d9b20e94
landlock: Fix TCP handling of short AF_UNSPEC addresses

current_check_access_socket() treats AF_UNSPEC addresses as
AF_INET ones, and only later adds special case handling to
allow connect(AF_UNSPEC), and on IPv4 sockets
bind(AF_UNSPEC+INADDR_ANY).
This would be fine except AF_UNSPEC addresses can be as
short as a bare AF_UNSPEC sa_family_t field, and nothing
more. The AF_INET code path incorrectly enforces a length of
sizeof(struct sockaddr_in) instead.

Move AF_UNSPEC edge case handling up inside the switch-case,
before the address is (potentially incorrectly) treated as
AF_INET.

Fixes: fff69fb03dde ("landlock: Support network rules with TCP bind and connect")
Signed-off-by: Matthieu Buffet <matthieu@buffet.re>
Link: https://lore.kernel.org/r/20251027190726.626244-4-matthieu@buffet.re
Signed-off-by: Mickaël Salaün <mic@digikod.net>
security/landlock/net.c