Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
ipv6: fix restrict IPV6_ADDRFORM operation
Browse files Browse the repository at this point in the history
Commit b6f6118 ("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: b6f6118 ("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>
(cherry picked from commit 82c9ae4)
Signed-off-by: Christoph Paasch <cpaasch@apple.com>
  • Loading branch information
jchax authored and cpaasch committed Apr 22, 2020
1 parent 6ffb496 commit f04a56b
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions net/ipv6/ipv6_sockglue.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,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;
Expand Down

0 comments on commit f04a56b

Please sign in to comment.