mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-07-08 18:13:59 +02:00
ipv6: fix a race in ip6_sock_set_v6only()
[ Upstream commit452a3eee22] It is unlikely that this function will be ever called with isk->inet_num being not zero. Perform the check on isk->inet_num inside the locked section for complete safety. Fixes:9b115749ac("ipv6: add ip6_sock_set_v6only") Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Simon Horman <horms@kernel.org> Reviewed-by: Fernando Fernandez Mancera <fmancera@suse.de> Link: https://patch.msgid.link/20260216102202.3343588-1-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Sasha Levin
parent
8277239e8a
commit
aca2d353a4
+7
-4
@@ -1177,12 +1177,15 @@ int ipv6_sock_mc_drop(struct sock *sk, int ifindex,
|
||||
|
||||
static inline int ip6_sock_set_v6only(struct sock *sk)
|
||||
{
|
||||
if (inet_sk(sk)->inet_num)
|
||||
return -EINVAL;
|
||||
int ret = 0;
|
||||
|
||||
lock_sock(sk);
|
||||
sk->sk_ipv6only = true;
|
||||
if (inet_sk(sk)->inet_num)
|
||||
ret = -EINVAL;
|
||||
else
|
||||
sk->sk_ipv6only = true;
|
||||
release_sock(sk);
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void ip6_sock_set_recverr(struct sock *sk)
|
||||
|
||||
Reference in New Issue
Block a user