* [PATCH net] net: fix possible store tearing in neigh_periodic_work()
@ 2023-09-21 8:46 Eric Dumazet
2023-09-21 19:33 ` David Ahern
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Eric Dumazet @ 2023-09-21 8:46 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: netdev, eric.dumazet, Eric Dumazet
While looking at a related syzbot report involving neigh_periodic_work(),
I found that I forgot to add an annotation when deleting an
RCU protected item from a list.
Readers use rcu_deference(*np), we need to use either
rcu_assign_pointer() or WRITE_ONCE() on writer side
to prevent store tearing.
I use rcu_assign_pointer() to have lockdep support,
this was the choice made in neigh_flush_dev().
Fixes: 767e97e1e0db ("neigh: RCU conversion of struct neighbour")
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/core/neighbour.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 6b76cd103195374f73786b7bb94fb2f4051a3c73..7212c7e521ef6388f450f3882077e26088bb3644 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -988,7 +988,9 @@ static void neigh_periodic_work(struct work_struct *work)
(state == NUD_FAILED ||
!time_in_range_open(jiffies, n->used,
n->used + NEIGH_VAR(n->parms, GC_STALETIME)))) {
- *np = n->next;
+ rcu_assign_pointer(*np,
+ rcu_dereference_protected(n->next,
+ lockdep_is_held(&tbl->lock)));
neigh_mark_dead(n);
write_unlock(&n->lock);
neigh_cleanup_and_release(n);
--
2.42.0.459.ge4e396fd5e-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: fix possible store tearing in neigh_periodic_work()
2023-09-21 8:46 [PATCH net] net: fix possible store tearing in neigh_periodic_work() Eric Dumazet
@ 2023-09-21 19:33 ` David Ahern
2023-09-22 9:49 ` Simon Horman
2023-10-01 15:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: David Ahern @ 2023-09-21 19:33 UTC (permalink / raw)
To: Eric Dumazet, David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: netdev, eric.dumazet
On 9/21/23 2:46 AM, Eric Dumazet wrote:
> While looking at a related syzbot report involving neigh_periodic_work(),
> I found that I forgot to add an annotation when deleting an
> RCU protected item from a list.
>
> Readers use rcu_deference(*np), we need to use either
> rcu_assign_pointer() or WRITE_ONCE() on writer side
> to prevent store tearing.
>
> I use rcu_assign_pointer() to have lockdep support,
> this was the choice made in neigh_flush_dev().
>
> Fixes: 767e97e1e0db ("neigh: RCU conversion of struct neighbour")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---
> net/core/neighbour.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
Reviewed-by: David Ahern <dsahern@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: fix possible store tearing in neigh_periodic_work()
2023-09-21 8:46 [PATCH net] net: fix possible store tearing in neigh_periodic_work() Eric Dumazet
2023-09-21 19:33 ` David Ahern
@ 2023-09-22 9:49 ` Simon Horman
2023-10-01 15:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2023-09-22 9:49 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, netdev,
eric.dumazet
On Thu, Sep 21, 2023 at 08:46:26AM +0000, Eric Dumazet wrote:
> While looking at a related syzbot report involving neigh_periodic_work(),
> I found that I forgot to add an annotation when deleting an
> RCU protected item from a list.
>
> Readers use rcu_deference(*np), we need to use either
> rcu_assign_pointer() or WRITE_ONCE() on writer side
> to prevent store tearing.
>
> I use rcu_assign_pointer() to have lockdep support,
> this was the choice made in neigh_flush_dev().
>
> Fixes: 767e97e1e0db ("neigh: RCU conversion of struct neighbour")
> 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] net: fix possible store tearing in neigh_periodic_work()
2023-09-21 8:46 [PATCH net] net: fix possible store tearing in neigh_periodic_work() Eric Dumazet
2023-09-21 19:33 ` David Ahern
2023-09-22 9:49 ` Simon Horman
@ 2023-10-01 15:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-10-01 15:30 UTC (permalink / raw)
To: Eric Dumazet; +Cc: davem, kuba, pabeni, netdev, eric.dumazet
Hello:
This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:
On Thu, 21 Sep 2023 08:46:26 +0000 you wrote:
> While looking at a related syzbot report involving neigh_periodic_work(),
> I found that I forgot to add an annotation when deleting an
> RCU protected item from a list.
>
> Readers use rcu_deference(*np), we need to use either
> rcu_assign_pointer() or WRITE_ONCE() on writer side
> to prevent store tearing.
>
> [...]
Here is the summary with links:
- [net] net: fix possible store tearing in neigh_periodic_work()
https://git.kernel.org/netdev/net/c/25563b581ba3
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:[~2023-10-01 15:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-21 8:46 [PATCH net] net: fix possible store tearing in neigh_periodic_work() Eric Dumazet
2023-09-21 19:33 ` David Ahern
2023-09-22 9:49 ` Simon Horman
2023-10-01 15:30 ` 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;
as well as URLs for NNTP newsgroup(s).