linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] infiniband: i40iw: fix a potential NULL pointer dereference
@ 2019-12-30  2:24 Xiyu Yang
  2019-12-30 13:30 ` Markus Elfring
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Xiyu Yang @ 2019-12-30  2:24 UTC (permalink / raw)
  To: xiyuyang19
  Cc: yuanxzhang, kjlu, leon, Markus.Elfring, Xin Tan, Faisal Latif,
	Shiraz Saleem, Doug Ledford, Jason Gunthorpe, Shannon Nelson,
	Anjali Singhai Jain, linux-rdma, linux-kernel

A NULL pointer can be returned by in_dev_get(). Thus add
a corresponding check so that a NULL pointer dereference
will be avoided at this place.

Fixes: 8e06af711bf2 ("i40iw: add main, hdr, status")
Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
---
Changes in v2:
- Release rtnl lock when in_dev_get return NULL
Changes in v3:
- Continue the next loop when in_dev_get return NULL
Changes in v4:
- Change commit message

 drivers/infiniband/hw/i40iw/i40iw_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/infiniband/hw/i40iw/i40iw_main.c b/drivers/infiniband/hw/i40iw/i40iw_main.c
index d44cf33df81a..238614370927 100644
--- a/drivers/infiniband/hw/i40iw/i40iw_main.c
+++ b/drivers/infiniband/hw/i40iw/i40iw_main.c
@@ -1225,6 +1225,8 @@ static void i40iw_add_ipv4_addr(struct i40iw_device *iwdev)
 			const struct in_ifaddr *ifa;
 
 			idev = in_dev_get(dev);
+			if (!idev)
+				continue;
 			in_dev_for_each_ifa_rtnl(ifa, idev) {
 				i40iw_debug(&iwdev->sc_dev, I40IW_DEBUG_CM,
 					    "IP=%pI4, vlan_id=%d, MAC=%pM\n", &ifa->ifa_address,
-- 
2.7.4


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

* Re: [PATCH v4] infiniband: i40iw: fix a potential NULL pointer dereference
  2019-12-30  2:24 [PATCH v4] infiniband: i40iw: fix a potential NULL pointer dereference Xiyu Yang
@ 2019-12-30 13:30 ` Markus Elfring
  2020-01-02 16:09 ` Saleem, Shiraz
  2020-01-04  0:01 ` Jason Gunthorpe
  2 siblings, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2019-12-30 13:30 UTC (permalink / raw)
  To: Xiyu Yang
  Cc: Yuan Zhang, Kangjie Lu, Leon Romanovsky, Xin Tan, Faisal Latif,
	Shiraz Saleem, Doug Ledford, Jason Gunthorpe, Shannon Nelson,
	Anjali Singhai Jain, linux-rdma, linux-kernel

I suggest to reconsider the distribution of mail addresses for subsequent patches.
I would find it more appropriate to put your address in the field “Cc”
while others should probably be specified in the message field “To”.

Regards,
Markus

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

* RE: [PATCH v4] infiniband: i40iw: fix a potential NULL pointer dereference
  2019-12-30  2:24 [PATCH v4] infiniband: i40iw: fix a potential NULL pointer dereference Xiyu Yang
  2019-12-30 13:30 ` Markus Elfring
@ 2020-01-02 16:09 ` Saleem, Shiraz
  2020-01-04  0:01 ` Jason Gunthorpe
  2 siblings, 0 replies; 5+ messages in thread
From: Saleem, Shiraz @ 2020-01-02 16:09 UTC (permalink / raw)
  To: Xiyu Yang
  Cc: yuanxzhang, kjlu, leon, Markus.Elfring, Xin Tan, Latif, Faisal,
	Doug Ledford, Jason Gunthorpe, Shannon Nelson, Singhai, Anjali,
	linux-rdma, linux-kernel

> Subject: [PATCH v4] infiniband: i40iw: fix a potential NULL pointer dereference
> 
> A NULL pointer can be returned by in_dev_get(). Thus add a corresponding check
> so that a NULL pointer dereference will be avoided at this place.
> 
> Fixes: 8e06af711bf2 ("i40iw: add main, hdr, status")
> Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
> Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
> Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
> ---
> Changes in v2:
> - Release rtnl lock when in_dev_get return NULL Changes in v3:
> - Continue the next loop when in_dev_get return NULL Changes in v4:
> - Change commit message
> 

Thanks! Looks ok.

I believe Leon caught another issue in how rtnl locking scheme is done in this function.
Will fix.

Shiraz

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

* Re: [PATCH v4] infiniband: i40iw: fix a potential NULL pointer dereference
  2019-12-30  2:24 [PATCH v4] infiniband: i40iw: fix a potential NULL pointer dereference Xiyu Yang
  2019-12-30 13:30 ` Markus Elfring
  2020-01-02 16:09 ` Saleem, Shiraz
@ 2020-01-04  0:01 ` Jason Gunthorpe
  2020-01-07  2:08   ` Saleem, Shiraz
  2 siblings, 1 reply; 5+ messages in thread
From: Jason Gunthorpe @ 2020-01-04  0:01 UTC (permalink / raw)
  To: Xiyu Yang
  Cc: yuanxzhang, kjlu, leon, Markus.Elfring, Xin Tan, Faisal Latif,
	Shiraz Saleem, Doug Ledford, Shannon Nelson, Anjali Singhai Jain,
	linux-rdma, linux-kernel

On Mon, Dec 30, 2019 at 10:24:28AM +0800, Xiyu Yang wrote:
> A NULL pointer can be returned by in_dev_get(). Thus add
> a corresponding check so that a NULL pointer dereference
> will be avoided at this place.
> 
> Fixes: 8e06af711bf2 ("i40iw: add main, hdr, status")
> Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
> Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
> Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
> ---
> Changes in v2:
> - Release rtnl lock when in_dev_get return NULL
> Changes in v3:
> - Continue the next loop when in_dev_get return NULL
> Changes in v4:
> - Change commit message
> 
>  drivers/infiniband/hw/i40iw/i40iw_main.c | 2 ++
>  1 file changed, 2 insertions(+)

Applied to for-next

And Shiraz, Leon is right, that trylock stuff is completely wrong,
let's fix it.

Jason

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

* RE: [PATCH v4] infiniband: i40iw: fix a potential NULL pointer dereference
  2020-01-04  0:01 ` Jason Gunthorpe
@ 2020-01-07  2:08   ` Saleem, Shiraz
  0 siblings, 0 replies; 5+ messages in thread
From: Saleem, Shiraz @ 2020-01-07  2:08 UTC (permalink / raw)
  To: Jason Gunthorpe, Xiyu Yang
  Cc: yuanxzhang, kjlu, leon, Markus.Elfring, Xin Tan, Latif, Faisal,
	Doug Ledford, Shannon Nelson, Singhai, Anjali, linux-rdma,
	linux-kernel

> Subject: Re: [PATCH v4] infiniband: i40iw: fix a potential NULL pointer dereference
> 
> On Mon, Dec 30, 2019 at 10:24:28AM +0800, Xiyu Yang wrote:
> > A NULL pointer can be returned by in_dev_get(). Thus add a
> > corresponding check so that a NULL pointer dereference will be avoided
> > at this place.
> >
> > Fixes: 8e06af711bf2 ("i40iw: add main, hdr, status")
> > Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
> > Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
> > Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
> > ---
> > Changes in v2:
> > - Release rtnl lock when in_dev_get return NULL Changes in v3:
> > - Continue the next loop when in_dev_get return NULL Changes in v4:
> > - Change commit message
> >
> >  drivers/infiniband/hw/i40iw/i40iw_main.c | 2 ++
> >  1 file changed, 2 insertions(+)
> 
> Applied to for-next
> 
> And Shiraz, Leon is right, that trylock stuff is completely wrong, let's fix it.
> 

Sure.

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

end of thread, other threads:[~2020-01-07  2:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-30  2:24 [PATCH v4] infiniband: i40iw: fix a potential NULL pointer dereference Xiyu Yang
2019-12-30 13:30 ` Markus Elfring
2020-01-02 16:09 ` Saleem, Shiraz
2020-01-04  0:01 ` Jason Gunthorpe
2020-01-07  2:08   ` Saleem, Shiraz

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).