Message ID | 20210609075945.3976469-1-eric.dumazet@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | dcd01eeac14486b56a790f5cce9b823440ba5b34 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net] inet: annotate data race in inet_send_prepare() and inet_dgram_connect() | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | fail | Series targets non-next tree, but doesn't contain any Fixes tags |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | warning | 2 maintainers not CCed: yoshfuji@linux-ipv6.org dsahern@kernel.org |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 2 this patch: 2 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | warning | WARNING: Possible repeated word: 'Google' WARNING: data_race without comment |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 2 this patch: 2 |
netdev/header_inline | success | Link |
Hello: This patch was applied to netdev/net.git (refs/heads/master): On Wed, 9 Jun 2021 00:59:45 -0700 you wrote: > From: Eric Dumazet <edumazet@google.com> > > Both functions are known to be racy when reading inet_num > as we do not want to grab locks for the common case the socket > has been bound already. The race is resolved in inet_autobind() > by reading again inet_num under the socket lock. > > [...] Here is the summary with links: - [net] inet: annotate data race in inet_send_prepare() and inet_dgram_connect() https://git.kernel.org/netdev/net/c/dcd01eeac144 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index f17870ee558bbaa043c10dc5b8a61a3fa1304880..2f94d221c00e9888d0f5f3738593fda811215cc6 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -575,7 +575,7 @@ int inet_dgram_connect(struct socket *sock, struct sockaddr *uaddr, return err; } - if (!inet_sk(sk)->inet_num && inet_autobind(sk)) + if (data_race(!inet_sk(sk)->inet_num) && inet_autobind(sk)) return -EAGAIN; return sk->sk_prot->connect(sk, uaddr, addr_len); } @@ -803,7 +803,7 @@ int inet_send_prepare(struct sock *sk) sock_rps_record_flow(sk); /* We may need to bind the socket. */ - if (!inet_sk(sk)->inet_num && !sk->sk_prot->no_autobind && + if (data_race(!inet_sk(sk)->inet_num) && !sk->sk_prot->no_autobind && inet_autobind(sk)) return -EAGAIN;