Skip to content

Commit

Permalink
selinux: correctly handle sa_family cases in selinux_sctp_bind_connect()
Browse files Browse the repository at this point in the history
Allow to pass the socket address structure with AF_UNSPEC family for
compatibility purposes. selinux_socket_bind() will further check it
for INADDR_ANY and selinux_socket_connect_helper() should return
EINVAL.

For a bad address family return EINVAL instead of AFNOSUPPORT error,
i.e. what is expected from SCTP protocol in such case.

Fixes: d452930 ("selinux: Add SCTP support")
Suggested-by: Paul Moore <[email protected]>
Signed-off-by: Alexey Kodanev <[email protected]>
Signed-off-by: Paul Moore <[email protected]>
  • Loading branch information
akodanev authored and pcmoore committed May 14, 2018
1 parent 88b7d37 commit 4152dc9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -5269,14 +5269,15 @@ static int selinux_sctp_bind_connect(struct sock *sk, int optname,
while (walk_size < addrlen) {
addr = addr_buf;
switch (addr->sa_family) {
case AF_UNSPEC:
case AF_INET:
len = sizeof(struct sockaddr_in);
break;
case AF_INET6:
len = sizeof(struct sockaddr_in6);
break;
default:
return -EAFNOSUPPORT;
return -EINVAL;
}

err = -EINVAL;
Expand Down

0 comments on commit 4152dc9

Please sign in to comment.