summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJohn Haxby <john.haxby@oracle.com>2020-04-18 16:30:49 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-05-02 17:24:16 +0200
commite7dff38799ee7f3e867a880b26697b03d3b74744 (patch)
treecc6db6e82a856c22558314f9a9eb4b36a627d53b /net
parente62f0f18405006eae5b362c6b3182cda1d1b3950 (diff)
downloadlinux-stable-e7dff38799ee7f3e867a880b26697b03d3b74744.tar.gz
linux-stable-e7dff38799ee7f3e867a880b26697b03d3b74744.tar.bz2
linux-stable-e7dff38799ee7f3e867a880b26697b03d3b74744.zip
ipv6: fix restrict IPV6_ADDRFORM operation
[ Upstream commit 82c9ae440857840c56e05d4fb1427ee032531346 ] Commit b6f6118901d1 ("ipv6: restrict IPV6_ADDRFORM operation") fixed a problem found by syzbot an unfortunate logic error meant that it also broke IPV6_ADDRFORM. Rearrange the checks so that the earlier test is just one of the series of checks made before moving the socket from IPv6 to IPv4. Fixes: b6f6118901d1 ("ipv6: restrict IPV6_ADDRFORM operation") Signed-off-by: John Haxby <john.haxby@oracle.com> Cc: stable@vger.kernel.org Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r--net/ipv6/ipv6_sockglue.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 8c492471b0da..337b43d4c3eb 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -185,15 +185,14 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
retv = -EBUSY;
break;
}
- } else if (sk->sk_protocol == IPPROTO_TCP) {
- if (sk->sk_prot != &tcpv6_prot) {
- retv = -EBUSY;
- break;
- }
- break;
- } else {
+ }
+ if (sk->sk_protocol == IPPROTO_TCP &&
+ sk->sk_prot != &tcpv6_prot) {
+ retv = -EBUSY;
break;
}
+ if (sk->sk_protocol != IPPROTO_TCP)
+ break;
if (sk->sk_state != TCP_ESTABLISHED) {
retv = -ENOTCONN;
break;