Skip to content

Commit 034294f

Browse files
sm1ling-knightpcmoore
authored andcommitted
selinux: Fix SCTP error inconsistency in selinux_socket_bind()
Check sk->sk_protocol instead of security class to recognize SCTP socket. SCTP socket is initialized with SECCLASS_SOCKET class if policy does not support EXTSOCKCLASS capability. In this case bind(2) hook wrongfully return EAFNOSUPPORT instead of EINVAL. The inconsistency was detected with help of Landlock tests: https://lore.kernel.org/all/[email protected]/ Fixes: 0f8db8c ("selinux: add AF_UNSPEC and INADDR_ANY checks to selinux_socket_bind()") Signed-off-by: Mikhail Ivanov <[email protected]> Signed-off-by: Paul Moore <[email protected]>
1 parent c75c794 commit 034294f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

security/selinux/hooks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4835,7 +4835,7 @@ static int selinux_socket_bind(struct socket *sock, struct sockaddr *address, in
48354835
return err;
48364836
err_af:
48374837
/* Note that SCTP services expect -EINVAL, others -EAFNOSUPPORT. */
4838-
if (sksec->sclass == SECCLASS_SCTP_SOCKET)
4838+
if (sk->sk_protocol == IPPROTO_SCTP)
48394839
return -EINVAL;
48404840
return -EAFNOSUPPORT;
48414841
}

0 commit comments

Comments
 (0)