aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/inetpeer.c
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2017-09-01 17:03:32 -0400
committerDavid S. Miller <davem@davemloft.net>2017-09-01 20:33:17 -0400
commit4cc5b44b29a9de9b3f841efedaa3f769066c63cc (patch)
tree2a98212b93c7c09a10a29c57754f3bc8cde99627 /net/ipv4/inetpeer.c
parentbbd9644e84f68587ed136c7e1c56e454c26231ff (diff)
inetpeer: fix RCU lookup()
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> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/inetpeer.c')
-rw-r--r--net/ipv4/inetpeer.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
index 337ad41bb80a..e7eb590c86ce 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,
102 struct rb_node **parent_p, 102 struct rb_node **parent_p,
103 struct rb_node ***pp_p) 103 struct rb_node ***pp_p)
104{ 104{
105 struct rb_node **pp, *parent; 105 struct rb_node **pp, *parent, *next;
106 struct inet_peer *p; 106 struct inet_peer *p;
107 107
108 pp = &base->rb_root.rb_node; 108 pp = &base->rb_root.rb_node;
109 parent = NULL; 109 parent = NULL;
110 while (*pp) { 110 while (1) {
111 int cmp; 111 int cmp;
112 112
113 parent = rcu_dereference_raw(*pp); 113 next = rcu_dereference_raw(*pp);
114 if (!next)
115 break;
116 parent = next;
114 p = rb_entry(parent, struct inet_peer, rb_node); 117 p = rb_entry(parent, struct inet_peer, rb_node);
115 cmp = inetpeer_addr_cmp(daddr, &p->daddr); 118 cmp = inetpeer_addr_cmp(daddr, &p->daddr);
116 if (cmp == 0) { 119 if (cmp == 0) {