ipv6: fix a race in ip6_sock_set_v6only()
Subsystems (3)
PATCH 1/1 ipv6: fix a race in ip6_sock_set_v6only()
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.
--- include/net/ipv6.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
include/net/ipv6.h +7 -4
@@ -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)
Signature · 1 line
2.53.0.310.g728cabbaf7-goog
Quoted 8 lines · Eric Dumazet
It is unlikely that this function will be ever called with
isk->inet_numbeing not zero.Perform the check on
isk->inet_numinside the locked section for complete safety.Fixes 9b115749acb24 ("ipv6: add ip6_sock_set_v6only")Signed-off-by Eric Dumazet <[email protected]>
Quoted 8 lines · Eric Dumazet
It is unlikely that this function will be ever called with
isk->inet_numbeing not zero.Perform the check on
isk->inet_numinside the locked section for complete safety.Fixes 9b115749acb24 ("ipv6: add ip6_sock_set_v6only")Signed-off-by Eric Dumazet <[email protected]>
Thanks!
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Mon, 16 Feb 2026 10:22:02 +0000 you wrote:
It is unlikely that this function will be ever called with
isk->inet_numbeing not zero.Perform the check on
isk->inet_numinside the locked section for complete safety.Fixes 9b115749acb24 ("ipv6: add ip6_sock_set_v6only")Signed-off-by Eric Dumazet <[email protected]>[...]
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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html