diff mbox

RDMA/addr: Use appropriate locking with for_each_netdev()

Message ID 4B0628E0.6000404@gmail.com
State Not Applicable, archived
Delegated to: David Miller
Headers show

Commit Message

Eric Dumazet Nov. 20, 2009, 5:28 a.m. UTC
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@gmail.com>
---
 drivers/infiniband/core/addr.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)


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

Comments

stephen hemminger Nov. 20, 2009, 5:40 a.m. UTC | #1
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...
Eric Dumazet Nov. 20, 2009, 5:43 a.m. UTC | #2
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
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Roland Dreier Nov. 20, 2009, 6:48 a.m. UTC | #3
> 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 netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eric Dumazet Nov. 20, 2009, 6:51 a.m. UTC | #4
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 netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Roland Dreier Nov. 23, 2009, 4:18 a.m. UTC | #5
> 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!
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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