Skip to content

Commit 82c9ae4

Browse files
jchaxdavem330
authored andcommitted
ipv6: fix restrict IPV6_ADDRFORM operation
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 <[email protected]> Cc: [email protected] Signed-off-by: David S. Miller <[email protected]>
1 parent bdbe05b commit 82c9ae4

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

net/ipv6/ipv6_sockglue.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,14 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
183183
retv = -EBUSY;
184184
break;
185185
}
186-
} else if (sk->sk_protocol == IPPROTO_TCP) {
187-
if (sk->sk_prot != &tcpv6_prot) {
188-
retv = -EBUSY;
189-
break;
190-
}
191-
break;
192-
} else {
186+
}
187+
if (sk->sk_protocol == IPPROTO_TCP &&
188+
sk->sk_prot != &tcpv6_prot) {
189+
retv = -EBUSY;
193190
break;
194191
}
192+
if (sk->sk_protocol != IPPROTO_TCP)
193+
break;
195194
if (sk->sk_state != TCP_ESTABLISHED) {
196195
retv = -ENOTCONN;
197196
break;

0 commit comments

Comments
 (0)