mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2024-12-29 09:12:07 +00:00
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/b58680ca-81b2-7222-7287-0ac7f4227c3c@huawei-partners.com/
Fixes: 0f8db8cc73
("selinux: add AF_UNSPEC and INADDR_ANY checks to selinux_socket_bind()")
Signed-off-by: Mikhail Ivanov <ivanov.mikhail1@huawei-partners.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
This commit is contained in:
parent
c75c7945cd
commit
034294fbfd
@ -4835,7 +4835,7 @@ static int selinux_socket_bind(struct socket *sock, struct sockaddr *address, in
|
||||
return err;
|
||||
err_af:
|
||||
/* Note that SCTP services expect -EINVAL, others -EAFNOSUPPORT. */
|
||||
if (sksec->sclass == SECCLASS_SCTP_SOCKET)
|
||||
if (sk->sk_protocol == IPPROTO_SCTP)
|
||||
return -EINVAL;
|
||||
return -EAFNOSUPPORT;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user