inet: read sk->sk_family once in inet_recv_error()
Subsystems (2)
PATCH 1/1 inet: read sk->sk_family once in inet_recv_error()
inet_recv_error() is called without holding the socket lock.
IPv6 socket could mutate to IPv4 with IPV6_ADDRFORM socket option and trigger a KCSAN warning.
Fixes f4713a3dfad0 ("net-timestamp: make tcp_recvmsg call ipv6_recv_error for AF_INET6 socks")
Signed-off-by Eric Dumazet <[email protected]>
Cc Willem de Bruijn <[email protected]>
--- net/ipv4/af_inet.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/ipv4/af_inet.c +4 -2
@@ -1628,10 +1628,12 @@ EXPORT_SYMBOL(inet_current_timestamp);int inet_recv_error (struct sock *sk,struct msghdr *msg,int len,int *addr_len) { -if (sk->sk_family ==AF_INET ) +unsigned int family =READ_ONCE (sk->sk_family); + +if (family ==AF_INET )return ip_recv_error (sk, msg, len, addr_len);#if IS_ENABLED (CONFIG_IPV6 ) -if (sk->sk_family ==AF_INET6 ) +if (family ==AF_INET6 )return pingv6_ops.ipv6_recv_error (sk, msg, len, addr_len);#endif return -EINVAL ;
Signature · 1 line
2.43.0.594.gd9cf4e227d-goog
Quoted 8 lines · Eric Dumazet
inet_recv_error()is called without holding the socket lock.IPv6 socket could mutate to IPv4 with
IPV6_ADDRFORMsocket option and trigger a KCSAN warning.Fixes f4713a3dfad0 ("net-timestamp: make tcp_recvmsg call ipv6_recv_error for AF_INET6 socks")Signed-off-by Eric Dumazet <[email protected]>Cc Willem de Bruijn <[email protected]>
Reviewed-by Willem de Bruijn <[email protected]>
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:
Quoted 10 lines · On Fri, 2 Feb 2024 09:54:04 +0000 you wrote:
inet_recv_error()is called without holding the socket lock.IPv6 socket could mutate to IPv4 with
IPV6_ADDRFORMsocket option and trigger a KCSAN warning.Fixes f4713a3dfad0 ("net-timestamp: make tcp_recvmsg call ipv6_recv_error for AF_INET6 socks")Signed-off-by Eric Dumazet <[email protected]>Cc Willem de Bruijn <[email protected]>[...]
Here is the summary with links:
- [net] inet: read sk->sk_family once in inet_recv_error()
https://git.kernel.org/netdev/net/c/eef00a82c568
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html