[Devel,RHEL7,COMMIT] ms/ipv6: fix a lockdep splat

Submitted by Konstantin Khorenko on June 20, 2017, 4:40 p.m.

Details

Message ID 201706201640.v5KGeDvu003469@finist_cl7.x64_64.work.ct
State New
Series "ms/ipv6: fix a lockdep splat"
Headers show

Commit Message

Konstantin Khorenko June 20, 2017, 4:40 p.m.
The commit is pushed to "branch-rh7-3.10.0-514.16.1.vz7.32.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.16.1.vz7.32.10
------>
commit e7f5e31908f4de6e2be5a1681d5dd52a74eef110
Author: Eric Dumazet <edumazet@google.com>
Date:   Tue Jun 20 20:40:13 2017 +0400

    ms/ipv6: fix a lockdep splat
    
    ML:44c3d0c1c0a880354e9de5d94175742e2c7c9683
    
    Silence lockdep false positive about rcu_dereference() being
    used in the wrong context.
    
    First one should use rcu_dereference_protected() as we own the spinlock.
    
    Second one should be a normal assignation, as no barrier is needed.
    
    Fixes: 18367681a10bd ("ipv6 flowlabel: Convert np->ipv6_fl_list to RCU.")
    Reported-by: Dave Jones <davej@codemonkey.org.uk>
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    
    https://jira.sw.ru/browse/PSBM-61714
    
    Signed-off-by: Igor Redko <redkoi@virtuozzo.com>
    Reviewed-by:	Vasily Averin <vvs@virtuozzo.com>
---
 net/ipv6/ip6_flowlabel.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index 06abaeb..9793548 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -498,12 +498,13 @@  int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen)
 	case IPV6_FL_A_PUT:
 		spin_lock_bh(&ip6_sk_fl_lock);
 		for (sflp = &np->ipv6_fl_list;
-		     (sfl = rcu_dereference(*sflp))!=NULL;
+		     (sfl = rcu_dereference_protected(*sflp,
+						      lockdep_is_held(&ip6_sk_fl_lock))) != NULL;
 		     sflp = &sfl->next) {
 			if (sfl->fl->label == freq.flr_label) {
 				if (freq.flr_label == (np->flow_label&IPV6_FLOWLABEL_MASK))
 					np->flow_label &= ~IPV6_FLOWLABEL_MASK;
-				*sflp = rcu_dereference(sfl->next);
+				*sflp = sfl->next;
 				spin_unlock_bh(&ip6_sk_fl_lock);
 				fl_release(sfl->fl);
 				kfree_rcu(sfl, rcu);