提交 6fc92b8b 编写于 作者: J John Haxby 提交者: Yang Yingliang

ipv6: fix restrict IPV6_ADDRFORM operation

stable inclusion
from linux-4.19.119
commit 387e87973d0d10b5f0025d45c27b39d2a7c1dd55

--------------------------------

[ Upstream commit 82c9ae44 ]

Commit b6f61189 ("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: b6f61189 ("ipv6: restrict IPV6_ADDRFORM operation")
Signed-off-by: NJohn Haxby <john.haxby@oracle.com>
Cc: stable@vger.kernel.org
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NLi Aichun <liaichun@huawei.com>
Reviewed-by: Nguodeqing <geffrey.guo@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 b2b9b8e3
...@@ -187,15 +187,14 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, ...@@ -187,15 +187,14 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
retv = -EBUSY; retv = -EBUSY;
break; break;
} }
} else if (sk->sk_protocol == IPPROTO_TCP) { }
if (sk->sk_prot != &tcpv6_prot) { if (sk->sk_protocol == IPPROTO_TCP &&
retv = -EBUSY; sk->sk_prot != &tcpv6_prot) {
break; retv = -EBUSY;
}
break;
} else {
break; break;
} }
if (sk->sk_protocol != IPPROTO_TCP)
break;
if (sk->sk_state != TCP_ESTABLISHED) { if (sk->sk_state != TCP_ESTABLISHED) {
retv = -ENOTCONN; retv = -ENOTCONN;
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册