* [PATCH net] ipv6: fix a race in ip6_sock_set_v6only()
@ 2026-02-16 10:22 Eric Dumazet
2026-02-17 14:58 ` Simon Horman
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Eric Dumazet @ 2026-02-16 10:22 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Kuniyuki Iwashima, David Ahern, netdev,
eric.dumazet, Eric Dumazet
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: 9b115749acb24 ("ipv6: add ip6_sock_set_v6only")
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/net/ipv6.h | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index cc56e09525d03b8e12dd92cec2751c2a13f16c10..53c5056508be543ae5d312e26dea6ed78fcc04ee 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -1213,12 +1213,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)
--
2.53.0.310.g728cabbaf7-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net] ipv6: fix a race in ip6_sock_set_v6only()
2026-02-16 10:22 [PATCH net] ipv6: fix a race in ip6_sock_set_v6only() Eric Dumazet
@ 2026-02-17 14:58 ` Simon Horman
2026-02-17 20:39 ` Fernando Fernandez Mancera
2026-02-18 1:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2026-02-17 14:58 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, Kuniyuki Iwashima,
David Ahern, netdev, eric.dumazet
On Mon, Feb 16, 2026 at 10:22:02AM +0000, Eric Dumazet wrote:
> 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: 9b115749acb24 ("ipv6: add ip6_sock_set_v6only")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH net] ipv6: fix a race in ip6_sock_set_v6only()
2026-02-16 10:22 [PATCH net] ipv6: fix a race in ip6_sock_set_v6only() Eric Dumazet
2026-02-17 14:58 ` Simon Horman
@ 2026-02-17 20:39 ` Fernando Fernandez Mancera
2026-02-18 1:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Fernando Fernandez Mancera @ 2026-02-17 20:39 UTC (permalink / raw)
To: Eric Dumazet, David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Kuniyuki Iwashima, David Ahern, netdev,
eric.dumazet
On 2/16/26 11:22 AM, Eric Dumazet wrote:
> 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: 9b115749acb24 ("ipv6: add ip6_sock_set_v6only")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Fernando Fernandez Mancera <fmancera@suse.de>
Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH net] ipv6: fix a race in ip6_sock_set_v6only()
2026-02-16 10:22 [PATCH net] ipv6: fix a race in ip6_sock_set_v6only() Eric Dumazet
2026-02-17 14:58 ` Simon Horman
2026-02-17 20:39 ` Fernando Fernandez Mancera
@ 2026-02-18 1:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-02-18 1:10 UTC (permalink / raw)
To: Eric Dumazet
Cc: davem, kuba, pabeni, horms, kuniyu, dsahern, netdev, eric.dumazet
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 16 Feb 2026 10:22:02 +0000 you wrote:
> 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: 9b115749acb24 ("ipv6: add ip6_sock_set_v6only")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
>
> [...]
Here is the summary with links:
- [net] ipv6: fix a race in ip6_sock_set_v6only()
https://git.kernel.org/netdev/net/c/452a3eee22c5
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-02-18 1:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-16 10:22 [PATCH net] ipv6: fix a race in ip6_sock_set_v6only() Eric Dumazet
2026-02-17 14:58 ` Simon Horman
2026-02-17 20:39 ` Fernando Fernandez Mancera
2026-02-18 1:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox