All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] IB/cma: Fix a race condition in iboe_addr_get_sgid()
@ 2016-12-19 17:00 Bart Van Assche
       [not found] ` <75d773f7-d8f2-a77d-6c7a-4991d71f0c9f-HInyCGIudOg@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Van Assche @ 2016-12-19 17:00 UTC (permalink / raw)
  To: Doug Ledford
  Cc: Moni Shoua, Or Gerlitz, Roland Dreier, Bart Van Assche,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

From: Bart Van Assche <bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>

Code that dereferences the struct net_device ip_ptr member must be
protected with an in_dev_get() / in_dev_put() pair. Hence insert
calls to these functions.

Fixes: commit 7b85627b9f02 ("IB/cma: IBoE (RoCE) IP-based GID addressing")
Signed-off-by: Bart Van Assche <bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
Reviewed-by: Moni Shoua <monis-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Cc: Or Gerlitz <ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Cc: Roland Dreier <roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org>
Cc: <stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
---
 include/rdma/ib_addr.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/rdma/ib_addr.h b/include/rdma/ib_addr.h
index 931a47ba4571..1beab5532035 100644
--- a/include/rdma/ib_addr.h
+++ b/include/rdma/ib_addr.h
@@ -205,10 +205,12 @@ static inline void iboe_addr_get_sgid(struct rdma_dev_addr *dev_addr,
 
 	dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if);
 	if (dev) {
-		ip4 = (struct in_device *)dev->ip_ptr;
-		if (ip4 && ip4->ifa_list && ip4->ifa_list->ifa_address)
+		ip4 = in_dev_get(dev);
+		if (ip4 && ip4->ifa_list && ip4->ifa_list->ifa_address) {
 			ipv6_addr_set_v4mapped(ip4->ifa_list->ifa_address,
 					       (struct in6_addr *)gid);
+			in_dev_put(ip4);
+		}
 		dev_put(dev);
 	}
 }
-- 
2.11.0

--
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] 5+ messages in thread

* Re: [PATCH] IB/cma: Fix a race condition in iboe_addr_get_sgid()
       [not found] ` <75d773f7-d8f2-a77d-6c7a-4991d71f0c9f-HInyCGIudOg@public.gmane.org>
@ 2016-12-22 16:40   ` Doug Ledford
  0 siblings, 0 replies; 5+ messages in thread
From: Doug Ledford @ 2016-12-22 16:40 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Moni Shoua, Or Gerlitz, Roland Dreier, Bart Van Assche,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA


[-- Attachment #1.1: Type: text/plain, Size: 948 bytes --]

On 12/19/2016 12:00 PM, Bart Van Assche wrote:
> From: Bart Van Assche <bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
> 
> Code that dereferences the struct net_device ip_ptr member must be
> protected with an in_dev_get() / in_dev_put() pair. Hence insert
> calls to these functions.
> 
> Fixes: commit 7b85627b9f02 ("IB/cma: IBoE (RoCE) IP-based GID addressing")
> Signed-off-by: Bart Van Assche <bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
> Reviewed-by: Moni Shoua <monis-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> Cc: Or Gerlitz <ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> Cc: Roland Dreier <roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org>
> Cc: <stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>

Thanks, applied.


-- 
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
    GPG Key ID: B826A3330E572FDD
    Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]

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

* Re: [PATCH] IB/cma: Fix a race condition in iboe_addr_get_sgid()
       [not found]     ` <CAG9sBKPu=R7ZeRnFD+-8jpiyVDok_MogzSF3H7mpgVZGZ9jX0Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2016-12-18 18:39       ` Doug Ledford
  0 siblings, 0 replies; 5+ messages in thread
From: Doug Ledford @ 2016-12-18 18:39 UTC (permalink / raw)
  To: Moni Shoua, Bart Van Assche; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA


[-- Attachment #1.1: Type: text/plain, Size: 832 bytes --]

On 12/18/2016 2:10 AM, Moni Shoua wrote:
> On Fri, Dec 16, 2016 at 3:39 PM, Bart Van Assche
> <bart.vanassche-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>> Hello Moni,
>>
>> Commit 7b85627b9f02 ("IB/cma: IBoE (RoCE) IP-based GID addressing") introduced code that
>> dereferences an RCU pointer without using rcu_read_lock(). Can you check whether the patch
>> below is the correct way to fix this?
>>
>> Thanks,
>>
>> Bart.
> 
> Hi Bart
> Fix looks good. Thanks
> 
> Reviewed-by: Moni Shoua <monis-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

Bart, can you please resend this patch with a proper commit message and
a SOB tag?


-- 
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
    GPG Key ID: B826A3330E572FDD
    Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]

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

* Re: [PATCH] IB/cma: Fix a race condition in iboe_addr_get_sgid()
       [not found] ` <811914f1-3bcc-a0a4-e20a-86e8b5853ac7-HInyCGIudOg@public.gmane.org>
@ 2016-12-18  7:10   ` Moni Shoua
       [not found]     ` <CAG9sBKPu=R7ZeRnFD+-8jpiyVDok_MogzSF3H7mpgVZGZ9jX0Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Moni Shoua @ 2016-12-18  7:10 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA

On Fri, Dec 16, 2016 at 3:39 PM, Bart Van Assche
<bart.vanassche-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Hello Moni,
>
> Commit 7b85627b9f02 ("IB/cma: IBoE (RoCE) IP-based GID addressing") introduced code that
> dereferences an RCU pointer without using rcu_read_lock(). Can you check whether the patch
> below is the correct way to fix this?
>
> Thanks,
>
> Bart.

Hi Bart
Fix looks good. Thanks

Reviewed-by: Moni Shoua <monis-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
--
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] 5+ messages in thread

* [PATCH] IB/cma: Fix a race condition in iboe_addr_get_sgid()
@ 2016-12-16 13:39 Bart Van Assche
       [not found] ` <811914f1-3bcc-a0a4-e20a-86e8b5853ac7-HInyCGIudOg@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Van Assche @ 2016-12-16 13:39 UTC (permalink / raw)
  To: Moni Shoua; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA

Hello Moni,

Commit 7b85627b9f02 ("IB/cma: IBoE (RoCE) IP-based GID addressing") introduced code that
dereferences an RCU pointer without using rcu_read_lock(). Can you check whether the patch
below is the correct way to fix this?

Thanks,

Bart.

---
 include/rdma/ib_addr.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/rdma/ib_addr.h b/include/rdma/ib_addr.h
index 931a47ba4571..1beab5532035 100644
--- a/include/rdma/ib_addr.h
+++ b/include/rdma/ib_addr.h
@@ -205,10 +205,12 @@ static inline void iboe_addr_get_sgid(struct rdma_dev_addr *dev_addr,
 
 	dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if);
 	if (dev) {
-		ip4 = (struct in_device *)dev->ip_ptr;
-		if (ip4 && ip4->ifa_list && ip4->ifa_list->ifa_address)
+		ip4 = in_dev_get(dev);
+		if (ip4 && ip4->ifa_list && ip4->ifa_list->ifa_address) {
 			ipv6_addr_set_v4mapped(ip4->ifa_list->ifa_address,
 					       (struct in6_addr *)gid);
+			in_dev_put(ip4);
+		}
 		dev_put(dev);
 	}
 }
-- 
2.11.0

--
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] 5+ messages in thread

end of thread, other threads:[~2016-12-22 16:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-19 17:00 [PATCH] IB/cma: Fix a race condition in iboe_addr_get_sgid() Bart Van Assche
     [not found] ` <75d773f7-d8f2-a77d-6c7a-4991d71f0c9f-HInyCGIudOg@public.gmane.org>
2016-12-22 16:40   ` Doug Ledford
  -- strict thread matches above, loose matches on Subject: below --
2016-12-16 13:39 Bart Van Assche
     [not found] ` <811914f1-3bcc-a0a4-e20a-86e8b5853ac7-HInyCGIudOg@public.gmane.org>
2016-12-18  7:10   ` Moni Shoua
     [not found]     ` <CAG9sBKPu=R7ZeRnFD+-8jpiyVDok_MogzSF3H7mpgVZGZ9jX0Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-12-18 18:39       ` Doug Ledford

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.