* [PATCH net-next] inetpeer: fix RCU lookup()
@ 2017-09-01 21:03 Eric Dumazet
2017-09-02 0:33 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2017-09-01 21:03 UTC (permalink / raw)
To: David Miller; +Cc: netdev
From: Eric Dumazet <edumazet@google.com>
Excess of seafood or something happened while I cooked the commit
adding RB tree to inetpeer.
Of course, RCU rules need to be respected or bad things can happen.
In this particular loop, we need to read *pp once per iteration, not
twice.
Fixes: b145425f269a ("inetpeer: remove AVL implementation in favor of RB tree")
Reported-by: John Sperbeck <jsperbeck@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/ipv4/inetpeer.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
index 337ad41bb80a5fcd3db7ac674292c5b5d462982e..e7eb590c86ce2b33654c17c61619de74ff07bfd1 100644
--- a/net/ipv4/inetpeer.c
+++ b/net/ipv4/inetpeer.c
@@ -102,15 +102,18 @@ static struct inet_peer *lookup(const struct inetpeer_addr *daddr,
struct rb_node **parent_p,
struct rb_node ***pp_p)
{
- struct rb_node **pp, *parent;
+ struct rb_node **pp, *parent, *next;
struct inet_peer *p;
pp = &base->rb_root.rb_node;
parent = NULL;
- while (*pp) {
+ while (1) {
int cmp;
- parent = rcu_dereference_raw(*pp);
+ next = rcu_dereference_raw(*pp);
+ if (!next)
+ break;
+ parent = next;
p = rb_entry(parent, struct inet_peer, rb_node);
cmp = inetpeer_addr_cmp(daddr, &p->daddr);
if (cmp == 0) {
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] inetpeer: fix RCU lookup()
2017-09-01 21:03 [PATCH net-next] inetpeer: fix RCU lookup() Eric Dumazet
@ 2017-09-02 0:33 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-09-02 0:33 UTC (permalink / raw)
To: eric.dumazet; +Cc: netdev
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 01 Sep 2017 14:03:32 -0700
> From: Eric Dumazet <edumazet@google.com>
>
> Excess of seafood or something happened while I cooked the commit
> adding RB tree to inetpeer.
>
> Of course, RCU rules need to be respected or bad things can happen.
>
> In this particular loop, we need to read *pp once per iteration, not
> twice.
>
> Fixes: b145425f269a ("inetpeer: remove AVL implementation in favor of RB tree")
> Reported-by: John Sperbeck <jsperbeck@google.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Cheers for excess seafood :-)
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-02 0:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-01 21:03 [PATCH net-next] inetpeer: fix RCU lookup() Eric Dumazet
2017-09-02 0:33 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.