aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Kodanev <alexey.kodanev@oracle.com>2018-05-11 13:15:13 -0400
committerPaul Moore <paul@paul-moore.com>2018-05-14 15:20:59 -0400
commit4152dc91b5932e7fe49a5afed62a068b2f31d196 (patch)
treedf0c291add6164031dbce1f413f585b77eb51758
parent88b7d370bb4b1280717ebdacd6748456f9ba484f (diff)
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: d452930fd3b9 ("selinux: Add SCTP support") Suggested-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
-rw-r--r--security/selinux/hooks.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index f5f2d6a582f0..efeb1db8f61d 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -5269,6 +5269,7 @@ static int selinux_sctp_bind_connect(struct sock *sk, int optname,
5269 while (walk_size < addrlen) { 5269 while (walk_size < addrlen) {
5270 addr = addr_buf; 5270 addr = addr_buf;
5271 switch (addr->sa_family) { 5271 switch (addr->sa_family) {
5272 case AF_UNSPEC:
5272 case AF_INET: 5273 case AF_INET:
5273 len = sizeof(struct sockaddr_in); 5274 len = sizeof(struct sockaddr_in);
5274 break; 5275 break;
@@ -5276,7 +5277,7 @@ static int selinux_sctp_bind_connect(struct sock *sk, int optname,
5276 len = sizeof(struct sockaddr_in6); 5277 len = sizeof(struct sockaddr_in6);
5277 break; 5278 break;
5278 default: 5279 default:
5279 return -EAFNOSUPPORT; 5280 return -EINVAL;
5280 } 5281 }
5281 5282
5282 err = -EINVAL; 5283 err = -EINVAL;