Do not check TCP access right if socket protocol is not IPPROTO_TCP. LANDLOCK_ACCESS_NET_BIND_TCP and LANDLOCK_ACCESS_NET_CONNECT_TCP should not restrict bind(2) and connect(2) for non-TCP protocols (SCTP, MPTCP, SMC). Closes: https://github.com/landlock-lsm/linux/issues/40 Fixes: fff69fb03dde ("landlock: Support network rules with TCP bind and connect") Signed-off-by: Mikhail Ivanov <ivanov.mikhail1@xxxxxxxxxxxxxxxxxxx> --- security/landlock/net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/landlock/net.c b/security/landlock/net.c index bc3d943a7118..6f59dd98bb13 100644 --- a/security/landlock/net.c +++ b/security/landlock/net.c @@ -68,7 +68,7 @@ static int current_check_access_socket(struct socket *const sock, return -EACCES; /* Checks if it's a (potential) TCP socket. */ - if (sock->type != SOCK_STREAM) + if (sock->type != SOCK_STREAM || sock->sk->sk_protocol != IPPROTO_TCP) return 0; /* Checks for minimal header length to safely read sa_family. */ -- 2.34.1