Message ID | 20211025181555.673034-1-eric.dumazet@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | d18785e213866935b4c3dc0c33c3e18801ce0ce8 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net-next] net: annotate data-race in neigh_output() | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Single patches do not need cover letters |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | success | CCed 3 of 3 maintainers |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 3119 this patch: 3119 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | No Fixes tag |
netdev/checkpatch | warning | WARNING: Possible repeated word: 'Google' |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 3163 this patch: 3163 |
netdev/header_inline | success | No static functions without inline keyword in header files |
Hello: This patch was applied to netdev/net-next.git (master) by David S. Miller <davem@davemloft.net>: On Mon, 25 Oct 2021 11:15:55 -0700 you wrote: > From: Eric Dumazet <edumazet@google.com> > > neigh_output() reads n->nud_state and hh->hh_len locklessly. > > This is fine, but we need to add annotations and document this. > > We evaluate skip_cache first to avoid reading these fields > if the cache has to by bypassed. > > [...] Here is the summary with links: - [net-next] net: annotate data-race in neigh_output() https://git.kernel.org/netdev/net-next/c/d18785e21386 You are awesome, thank you!
diff --git a/include/net/neighbour.h b/include/net/neighbour.h index e8e48be667552b20650d52941b48e405b7d0d9bd..38a0c1d2457087c2683792ec3b2277d071349bb9 100644 --- a/include/net/neighbour.h +++ b/include/net/neighbour.h @@ -516,10 +516,15 @@ static inline int neigh_output(struct neighbour *n, struct sk_buff *skb, { const struct hh_cache *hh = &n->hh; - if ((n->nud_state & NUD_CONNECTED) && hh->hh_len && !skip_cache) + /* n->nud_state and hh->hh_len could be changed under us. + * neigh_hh_output() is taking care of the race later. + */ + if (!skip_cache && + (READ_ONCE(n->nud_state) & NUD_CONNECTED) && + READ_ONCE(hh->hh_len)) return neigh_hh_output(hh, skb); - else - return n->output(n, skb); + + return n->output(n, skb); } static inline struct neighbour *