Commit 4152dc91 authored by Alexey Kodanev's avatar Alexey Kodanev Committed by Paul Moore

selinux: correctly handle sa_family cases in selinux_sctp_bind_connect()

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: d452930f ("selinux: Add SCTP support")
Suggested-by: default avatarPaul Moore <paul@paul-moore.com>
Signed-off-by: default avatarAlexey Kodanev <alexey.kodanev@oracle.com>
Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
parent 88b7d370
...@@ -5269,6 +5269,7 @@ static int selinux_sctp_bind_connect(struct sock *sk, int optname, ...@@ -5269,6 +5269,7 @@ static int selinux_sctp_bind_connect(struct sock *sk, int optname,
while (walk_size < addrlen) { while (walk_size < addrlen) {
addr = addr_buf; addr = addr_buf;
switch (addr->sa_family) { switch (addr->sa_family) {
case AF_UNSPEC:
case AF_INET: case AF_INET:
len = sizeof(struct sockaddr_in); len = sizeof(struct sockaddr_in);
break; break;
...@@ -5276,7 +5277,7 @@ static int selinux_sctp_bind_connect(struct sock *sk, int optname, ...@@ -5276,7 +5277,7 @@ static int selinux_sctp_bind_connect(struct sock *sk, int optname,
len = sizeof(struct sockaddr_in6); len = sizeof(struct sockaddr_in6);
break; break;
default: default:
return -EAFNOSUPPORT; return -EINVAL;
} }
err = -EINVAL; err = -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment