Commit 9c7db500 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'selinux-pr-20190521' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux

Pull SELinux fix from Paul Moore:
 "One small SELinux patch to fix a problem when disconnecting a SCTP
  socket with connect(AF_UNSPEC)"

* tag 'selinux-pr-20190521' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
  selinux: do not report error on connect(AF_UNSPEC)
parents 2c1212de 05174c95
...@@ -4637,6 +4637,14 @@ static int selinux_socket_connect_helper(struct socket *sock, ...@@ -4637,6 +4637,14 @@ static int selinux_socket_connect_helper(struct socket *sock,
err = sock_has_perm(sk, SOCKET__CONNECT); err = sock_has_perm(sk, SOCKET__CONNECT);
if (err) if (err)
return err; return err;
if (addrlen < offsetofend(struct sockaddr, sa_family))
return -EINVAL;
/* connect(AF_UNSPEC) has special handling, as it is a documented
* way to disconnect the socket
*/
if (address->sa_family == AF_UNSPEC)
return 0;
/* /*
* If a TCP, DCCP or SCTP socket, check name_connect permission * If a TCP, DCCP or SCTP socket, check name_connect permission
...@@ -4657,8 +4665,6 @@ static int selinux_socket_connect_helper(struct socket *sock, ...@@ -4657,8 +4665,6 @@ static int selinux_socket_connect_helper(struct socket *sock,
* need to check address->sa_family as it is possible to have * need to check address->sa_family as it is possible to have
* sk->sk_family = PF_INET6 with addr->sa_family = AF_INET. * sk->sk_family = PF_INET6 with addr->sa_family = AF_INET.
*/ */
if (addrlen < offsetofend(struct sockaddr, sa_family))
return -EINVAL;
switch (address->sa_family) { switch (address->sa_family) {
case AF_INET: case AF_INET:
addr4 = (struct sockaddr_in *)address; addr4 = (struct sockaddr_in *)address;
......
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