diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-21 12:51:20 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-21 12:51:20 -0700 |
commit | 9c7db5004280767566e91a33445bf93aa479ef02 (patch) | |
tree | a6db716f212ecfaf39b53cb37266be5010d09b96 /security | |
parent | 2c1212de6f9794a7becba5f219fa6ce8a8222c90 (diff) | |
parent | 05174c95b83f8aca0c47b87115abb7a6387aafa5 (diff) | |
download | linux-stable-9c7db5004280767566e91a33445bf93aa479ef02.tar.gz linux-stable-9c7db5004280767566e91a33445bf93aa479ef02.tar.bz2 linux-stable-9c7db5004280767566e91a33445bf93aa479ef02.zip |
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)
Diffstat (limited to 'security')
-rw-r--r-- | security/selinux/hooks.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index c61787b15f27..3ec702cf46ca 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -4637,6 +4637,14 @@ static int selinux_socket_connect_helper(struct socket *sock, err = sock_has_perm(sk, SOCKET__CONNECT); if (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 @@ -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 * sk->sk_family = PF_INET6 with addr->sa_family = AF_INET. */ - if (addrlen < offsetofend(struct sockaddr, sa_family)) - return -EINVAL; switch (address->sa_family) { case AF_INET: addr4 = (struct sockaddr_in *)address; |