Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1320419 > unrolled thread

[PATCH] ipv6: release idev lock before calling ipv6_ifa_notify()

Started byGregory Herrero <gregory.herrero@intel.com>
First post2016-01-28 09:40 +0100
Last post2016-01-30 02:50 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] ipv6: release idev lock before calling ipv6_ifa_notify() Gregory Herrero <gregory.herrero@intel.com> - 2016-01-28 09:40 +0100
    Re: [PATCH] ipv6: release idev lock before calling  ipv6_ifa_notify() David Miller <davem@davemloft.net> - 2016-01-30 02:50 +0100

#1320419 — [PATCH] ipv6: release idev lock before calling ipv6_ifa_notify()

FromGregory Herrero <gregory.herrero@intel.com>
Date2016-01-28 09:40 +0100
Subject[PATCH] ipv6: release idev lock before calling ipv6_ifa_notify()
Message-ID<qVQht-Jf-19@gated-at.bofh.it>
ipv6_ifa_notify() may need to acquire idev->lock, for example
when calling __ipv6_dev_ac_inc() from addrconf_join_anycast()
in __ipv6_ifa_notify().
So caller must release idev->lock before calling ipv6_ifa_notify() to
avoid a deadlock.
Fix a checkpatch warning present in the same area to make checkpatch
happy.

Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
---
 net/ipv6/addrconf.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 38eedde..af7fc84 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2302,8 +2302,11 @@ static void manage_tempaddrs(struct inet6_dev *idev,
 			ift->flags &= ~IFA_F_DEPRECATED;
 
 		spin_unlock(&ift->lock);
-		if (!(flags&IFA_F_TENTATIVE))
+		if (!(flags & IFA_F_TENTATIVE)) {
+			read_unlock_bh(&idev->lock);
 			ipv6_ifa_notify(0, ift);
+			read_lock_bh(&idev->lock);
+		}
 	}
 
 	if ((create || list_empty(&idev->tempaddr_list)) &&
@@ -3583,7 +3586,9 @@ static void addrconf_dad_begin(struct inet6_ifaddr *ifp)
 			/* Because optimistic nodes can use this address,
 			 * notify listeners. If DAD fails, RTM_DELADDR is sent.
 			 */
+			read_unlock_bh(&idev->lock);
 			ipv6_ifa_notify(RTM_NEWADDR, ifp);
+			read_lock_bh(&idev->lock);
 		}
 	}
 
-- 
2.6.2

[toc] | [next] | [standalone]


#1322228 — Re: [PATCH] ipv6: release idev lock before calling ipv6_ifa_notify()

FromDavid Miller <davem@davemloft.net>
Date2016-01-30 02:50 +0100
SubjectRe: [PATCH] ipv6: release idev lock before calling ipv6_ifa_notify()
Message-ID<qWsPM-3zi-9@gated-at.bofh.it>
In reply to#1320419
From: Gregory Herrero <gregory.herrero@intel.com>
Date: Thu, 28 Jan 2016 09:34:52 +0100

> @@ -2302,8 +2302,11 @@ static void manage_tempaddrs(struct inet6_dev *idev,
>  			ift->flags &= ~IFA_F_DEPRECATED;
>  
>  		spin_unlock(&ift->lock);
> -		if (!(flags&IFA_F_TENTATIVE))
> +		if (!(flags & IFA_F_TENTATIVE)) {
> +			read_unlock_bh(&idev->lock);
>  			ipv6_ifa_notify(0, ift);
> +			read_lock_bh(&idev->lock);
> +		}
>  	}
>  
>  	if ((create || list_empty(&idev->tempaddr_list)) &&

You can't do this, the idev->lock has to be held to keep the list we
are iterating over from changing.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web