aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2019-06-06 14:32:34 -0700
committerPaul Gortmaker <paul.gortmaker@windriver.com>2019-09-16 12:21:28 -0400
commit37773f3c07560abe24247be09ecc71af11dbca95 (patch)
tree5cfd71b6b39956e04b97e2af61d8d536389ffbac
parent07e403d23b68ac4e597c03326e67db5dd73e2db8 (diff)
downloadlinux-yocto-37773f3c07560abe24247be09ecc71af11dbca95.tar.gz
linux-yocto-37773f3c07560abe24247be09ecc71af11dbca95.tar.bz2
linux-yocto-37773f3c07560abe24247be09ecc71af11dbca95.zip
ipv6: flowlabel: fl6_sock_lookup() must use atomic_inc_not_zero
commit 65a3c497c0e965a552008db8bc2653f62bc925a1 upstream. Before taking a refcount, make sure the object is not already scheduled for deletion. Same fix is needed in ipv6_flowlabel_opt() Fixes: 18367681a10b ("ipv6 flowlabel: Convert np->ipv6_fl_list to RCU.") Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Willem de Bruijn <willemb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
-rw-r--r--net/ipv6/ip6_flowlabel.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index a119a71ab5b7..22ca0befcc64 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -254,9 +254,9 @@ struct ip6_flowlabel *fl6_sock_lookup(struct sock *sk, __be32 label)
rcu_read_lock_bh();
for_each_sk_fl_rcu(np, sfl) {
struct ip6_flowlabel *fl = sfl->fl;
- if (fl->label == label) {
+
+ if (fl->label == label && atomic_inc_not_zero(&fl->users)) {
fl->lastuse = jiffies;
- atomic_inc(&fl->users);
rcu_read_unlock_bh();
return fl;
}
@@ -623,7 +623,8 @@ int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen)
goto done;
}
fl1 = sfl->fl;
- atomic_inc(&fl1->users);
+ if (!atomic_inc_not_zero(&fl1->users))
+ fl1 = NULL;
break;
}
}