netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] RDMA/addr: Use appropriate locking with for_each_netdev()
@ 2009-11-10  4:27 Eric Dumazet
       [not found] ` <4AF8EBA4.2070102-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Dumazet @ 2009-11-10  4:27 UTC (permalink / raw)
  To: David S. Miller
  Cc: Linux Netdev List, Roland Dreier, Sean Hefty, Hal Rosenstock


for_each_netdev() should be used with RTNL or dev_base_lock held,
or risk a crash.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
 drivers/infiniband/core/addr.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index bd07803..5ca0b2c 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -131,6 +131,7 @@ int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr)
 
 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
 	case AF_INET6:
+		read_lock(&dev_base_lock);
 		for_each_netdev(&init_net, dev) {
 			if (ipv6_chk_addr(&init_net,
 					  &((struct sockaddr_in6 *) addr)->sin6_addr,
@@ -139,6 +140,7 @@ int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr)
 				break;
 			}
 		}
+		read_unlock(&dev_base_lock);
 		break;
 #endif
 	}
@@ -391,15 +393,17 @@ static int addr_resolve_local(struct sockaddr *src_in,
 	{
 		struct in6_addr *a;
 
+		read_lock(&dev_base_lock);
 		for_each_netdev(&init_net, dev)
 			if (ipv6_chk_addr(&init_net,
 					  &((struct sockaddr_in6 *) dst_in)->sin6_addr,
 					  dev, 1))
 				break;
 
-		if (!dev)
+		if (!dev) {
+			read_unlock(&dev_base_lock);
 			return -EADDRNOTAVAIL;
-
+		}
 		a = &((struct sockaddr_in6 *) src_in)->sin6_addr;
 
 		if (ipv6_addr_any(a)) {
@@ -416,6 +420,7 @@ static int addr_resolve_local(struct sockaddr *src_in,
 			if (!ret)
 				memcpy(addr->dst_dev_addr, dev->dev_addr, MAX_ADDR_LEN);
 		}
+		read_unlock(&dev_base_lock);
 		break;
 	}
 #endif

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* RE: [PATCH] RDMA/addr: Use appropriate locking with for_each_netdev()
       [not found] ` <4AF8EBA4.2070102-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2009-11-11 18:18   ` Sean Hefty
       [not found]     ` <D5E1FB213939498DBFFEB5A3B83C08AD-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Sean Hefty @ 2009-11-11 18:18 UTC (permalink / raw)
  To: 'Eric Dumazet', David S. Miller
  Cc: Linux Netdev List, Roland Dreier, Hal Rosenstock, linux-rdma

>for_each_netdev() should be used with RTNL or dev_base_lock held,
>or risk a crash.
>
>Signed-off-by: Eric Dumazet <eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Thanks - I'm working on a patch set in this area.  Roland, I can merge Eric's
changes into that patch set if it makes things easier.

> drivers/infiniband/core/addr.c |    9 +++++++--
> 1 files changed, 7 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
>index bd07803..5ca0b2c 100644
>--- a/drivers/infiniband/core/addr.c
>+++ b/drivers/infiniband/core/addr.c
>@@ -131,6 +131,7 @@ int rdma_translate_ip(struct sockaddr *addr, struct

The changes to this function are still valid.

>@@ -391,15 +393,17 @@ static int addr_resolve_local(struct sockaddr *src_in,

This function is going away.

- Sean

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] RDMA/addr: Use appropriate locking with for_each_netdev()
       [not found]     ` <D5E1FB213939498DBFFEB5A3B83C08AD-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
@ 2009-11-11 18:25       ` Roland Dreier
       [not found]         ` <adaocn8x6j7.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Roland Dreier @ 2009-11-11 18:25 UTC (permalink / raw)
  To: Sean Hefty
  Cc: 'Eric Dumazet', David S. Miller, Linux Netdev List,
	Roland Dreier, Hal Rosenstock, linux-rdma


 > >for_each_netdev() should be used with RTNL or dev_base_lock held,
 > >or risk a crash.
 > >
 > >Signed-off-by: Eric Dumazet <eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
 > 
 > Thanks - I'm working on a patch set in this area.  Roland, I can merge Eric's
 > changes into that patch set if it makes things easier.

Would it be possible for you to take Eric's patch as the first in your
set (keeping his From: of course) and base your fixes on top of that?
That seems the cleanest thing to me.

Thanks,
  Roland
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [PATCH] RDMA/addr: Use appropriate locking with for_each_netdev()
       [not found]         ` <adaocn8x6j7.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org>
@ 2009-11-11 20:55           ` Sean Hefty
       [not found]             ` <8C10E584257A46DB9A0AD193520CF4A7-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Sean Hefty @ 2009-11-11 20:55 UTC (permalink / raw)
  To: 'Roland Dreier'
  Cc: 'Eric Dumazet', David S. Miller, Linux Netdev List,
	Roland Dreier, Hal Rosenstock, linux-rdma

>Would it be possible for you to take Eric's patch as the first in your
>set (keeping his From: of course) and base your fixes on top of that?

Will do.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] RDMA/addr: Use appropriate locking with for_each_netdev()
       [not found]             ` <8C10E584257A46DB9A0AD193520CF4A7-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
@ 2009-11-20  5:28               ` Eric Dumazet
       [not found]                 ` <4B0628E0.6000404-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Dumazet @ 2009-11-20  5:28 UTC (permalink / raw)
  To: Sean Hefty
  Cc: 'Roland Dreier', David S. Miller, Linux Netdev List,
	Roland Dreier, Hal Rosenstock, linux-rdma

Sean Hefty a écrit :
>> Would it be possible for you to take Eric's patch as the first in your
>> set (keeping his From: of course) and base your fixes on top of that?
> 
> Will do.
> 

Any news of this patch ?

We need it for 2.6.32 and also to prepare 2.6.33 with upcoming patches.

Thanks

[PATCH] RDMA/addr: Use appropriate locking with for_each_netdev()

for_each_netdev() should be used with RTNL or dev_base_lock held,
or risk a crash.

Signed-off-by: Eric Dumazet <eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/infiniband/core/addr.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index bd07803..5ca0b2c 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -131,6 +131,7 @@ int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr)
 
 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
 	case AF_INET6:
+		read_lock(&dev_base_lock);
 		for_each_netdev(&init_net, dev) {
 			if (ipv6_chk_addr(&init_net,
 					  &((struct sockaddr_in6 *) addr)->sin6_addr,
@@ -139,6 +140,7 @@ int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr)
 				break;
 			}
 		}
+		read_unlock(&dev_base_lock);
 		break;
 #endif
 	}
@@ -391,15 +393,17 @@ static int addr_resolve_local(struct sockaddr *src_in,
 	{
 		struct in6_addr *a;
 
+		read_lock(&dev_base_lock);
 		for_each_netdev(&init_net, dev)
 			if (ipv6_chk_addr(&init_net,
 					  &((struct sockaddr_in6 *) dst_in)->sin6_addr,
 					  dev, 1))
 				break;
 
-		if (!dev)
+		if (!dev) {
+			read_unlock(&dev_base_lock);
 			return -EADDRNOTAVAIL;
-
+		}
 		a = &((struct sockaddr_in6 *) src_in)->sin6_addr;
 
 		if (ipv6_addr_any(a)) {
@@ -416,6 +420,7 @@ static int addr_resolve_local(struct sockaddr *src_in,
 			if (!ret)
 				memcpy(addr->dst_dev_addr, dev->dev_addr, MAX_ADDR_LEN);
 		}
+		read_unlock(&dev_base_lock);
 		break;
 	}
 #endif

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] RDMA/addr: Use appropriate locking with for_each_netdev()
       [not found]                 ` <4B0628E0.6000404-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2009-11-20  5:40                   ` Stephen Hemminger
  2009-11-20  5:43                     ` Eric Dumazet
  2009-11-20  6:48                   ` Roland Dreier
  1 sibling, 1 reply; 10+ messages in thread
From: Stephen Hemminger @ 2009-11-20  5:40 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Sean Hefty, 'Roland Dreier', David S. Miller,
	Linux Netdev List, Roland Dreier, Hal Rosenstock, linux-rdma

On Fri, 20 Nov 2009 06:28:00 +0100
Eric Dumazet <eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> +		read_lock(&dev_base_lock);
>  		for_each_netdev(&init_net, dev) {
>  			if (ipv6_chk_addr(&init_net,
>  					  &((struct sockaddr_in6 *) addr)->sin6_addr,
> @@ -139,6 +140,7 @@ int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr)
>  				break;
>  			}
>  		}
> +		read_unlock(&dev_base_lock);

what about for_each_netdev_rcu() here instead...



-- 
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] RDMA/addr: Use appropriate locking with for_each_netdev()
  2009-11-20  5:40                   ` Stephen Hemminger
@ 2009-11-20  5:43                     ` Eric Dumazet
  0 siblings, 0 replies; 10+ messages in thread
From: Eric Dumazet @ 2009-11-20  5:43 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: Sean Hefty, 'Roland Dreier', David S. Miller,
	Linux Netdev List, Roland Dreier, Hal Rosenstock, linux-rdma

Stephen Hemminger a écrit :
> On Fri, 20 Nov 2009 06:28:00 +0100
> Eric Dumazet <eric.dumazet@gmail.com> wrote:
> 
>> +		read_lock(&dev_base_lock);
>>  		for_each_netdev(&init_net, dev) {
>>  			if (ipv6_chk_addr(&init_net,
>>  					  &((struct sockaddr_in6 *) addr)->sin6_addr,
>> @@ -139,6 +140,7 @@ int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr)
>>  				break;
>>  			}
>>  		}
>> +		read_unlock(&dev_base_lock);
> 
> what about for_each_netdev_rcu() here instead...
> 

Yes, in 2.6.33 :)

For 2.6.32, we need this patch

Thanks

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] RDMA/addr: Use appropriate locking with for_each_netdev()
       [not found]                 ` <4B0628E0.6000404-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2009-11-20  5:40                   ` Stephen Hemminger
@ 2009-11-20  6:48                   ` Roland Dreier
       [not found]                     ` <adak4xl669z.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org>
  1 sibling, 1 reply; 10+ messages in thread
From: Roland Dreier @ 2009-11-20  6:48 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Sean Hefty, David S. Miller, Linux Netdev List, Roland Dreier,
	Hal Rosenstock, linux-rdma


 > Any news of this patch ?
 > 
 > We need it for 2.6.32 and also to prepare 2.6.33 with upcoming patches.

Sorry for not explicitly emailing about this patch.  I applied it as
part of Sean's series, but I just added it to my 2.6.33 queue.  At this
point in the release cycle it doesn't look severe enough for 2.6.32,
unless I miss something.

 - R.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] RDMA/addr: Use appropriate locking with for_each_netdev()
       [not found]                     ` <adak4xl669z.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org>
@ 2009-11-20  6:51                       ` Eric Dumazet
  2009-11-23  4:18                         ` Roland Dreier
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Dumazet @ 2009-11-20  6:51 UTC (permalink / raw)
  To: Roland Dreier
  Cc: Sean Hefty, David S. Miller, Linux Netdev List, Roland Dreier,
	Hal Rosenstock, linux-rdma

Roland Dreier a écrit :
>  > Any news of this patch ?
>  > 
>  > We need it for 2.6.32 and also to prepare 2.6.33 with upcoming patches.
> 
> Sorry for not explicitly emailing about this patch.  I applied it as
> part of Sean's series, but I just added it to my 2.6.33 queue.  At this
> point in the release cycle it doesn't look severe enough for 2.6.32,
> unless I miss something.

Its possible to get infinite loops or crashes.

I am not a RDMA user, so I personally dont care :)

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] RDMA/addr: Use appropriate locking with for_each_netdev()
  2009-11-20  6:51                       ` Eric Dumazet
@ 2009-11-23  4:18                         ` Roland Dreier
  0 siblings, 0 replies; 10+ messages in thread
From: Roland Dreier @ 2009-11-23  4:18 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Sean Hefty, David S. Miller, Linux Netdev List, Roland Dreier,
	Hal Rosenstock, linux-rdma


 > Its possible to get infinite loops or crashes.

 > I am not a RDMA user, so I personally dont care :)

I think given that it's not a regression, and I've never heard of anyone
hitting it in practice, we can wait until the merge window.

Thanks!

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-11-23  4:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-10  4:27 [PATCH] RDMA/addr: Use appropriate locking with for_each_netdev() Eric Dumazet
     [not found] ` <4AF8EBA4.2070102-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-11-11 18:18   ` Sean Hefty
     [not found]     ` <D5E1FB213939498DBFFEB5A3B83C08AD-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2009-11-11 18:25       ` Roland Dreier
     [not found]         ` <adaocn8x6j7.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org>
2009-11-11 20:55           ` Sean Hefty
     [not found]             ` <8C10E584257A46DB9A0AD193520CF4A7-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2009-11-20  5:28               ` Eric Dumazet
     [not found]                 ` <4B0628E0.6000404-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-11-20  5:40                   ` Stephen Hemminger
2009-11-20  5:43                     ` Eric Dumazet
2009-11-20  6:48                   ` Roland Dreier
     [not found]                     ` <adak4xl669z.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org>
2009-11-20  6:51                       ` Eric Dumazet
2009-11-23  4:18                         ` Roland Dreier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).