linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] RDMA/irdma: Fix potential NULL-ptr-dereference
@ 2023-01-26 18:52 Nikita Zhandarovich
  2023-01-27 15:38 ` Devale, Sindhu
  2023-01-29 12:57 ` Leon Romanovsky
  0 siblings, 2 replies; 3+ messages in thread
From: Nikita Zhandarovich @ 2023-01-26 18:52 UTC (permalink / raw)
  To: Mustafa Ismail
  Cc: Nikita Zhandarovich, Shiraz Saleem, Jason Gunthorpe,
	Leon Romanovsky, linux-rdma, linux-kernel, lvc-project

in_dev_get() can return NULL which will cause a failure once idev is
dereferenced in in_dev_for_each_ifa_rtnl(). This patch adds a
check for NULL value in idev beforehand.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 146b9756f14c ("RDMA/irdma: Add connection manager")
Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>

 drivers/infiniband/hw/irdma/cm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/infiniband/hw/irdma/cm.c b/drivers/infiniband/hw/irdma/cm.c
index 7b086fe63a24..195aa9ea18b6 100644
--- a/drivers/infiniband/hw/irdma/cm.c
+++ b/drivers/infiniband/hw/irdma/cm.c
@@ -1722,6 +1722,9 @@ static int irdma_add_mqh_4(struct irdma_device *iwdev,
 			continue;
 
 		idev = in_dev_get(ip_dev);
+		if (!idev)
+			continue;
+
 		in_dev_for_each_ifa_rtnl(ifa, idev) {
 			ibdev_dbg(&iwdev->ibdev,
 				  "CM: Allocating child CM Listener forIP=%pI4, vlan_id=%d, MAC=%pM\n",

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

* RE: [PATCH] RDMA/irdma: Fix potential NULL-ptr-dereference
  2023-01-26 18:52 [PATCH] RDMA/irdma: Fix potential NULL-ptr-dereference Nikita Zhandarovich
@ 2023-01-27 15:38 ` Devale, Sindhu
  2023-01-29 12:57 ` Leon Romanovsky
  1 sibling, 0 replies; 3+ messages in thread
From: Devale, Sindhu @ 2023-01-27 15:38 UTC (permalink / raw)
  To: Nikita Zhandarovich, Ismail, Mustafa
  Cc: Saleem, Shiraz, Jason Gunthorpe, Leon Romanovsky, linux-rdma,
	linux-kernel, lvc-project



> -----Original Message-----
> From: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
> Sent: Thursday, January 26, 2023 12:53 PM
> To: Ismail, Mustafa <mustafa.ismail@intel.com>
> Cc: Nikita Zhandarovich <n.zhandarovich@fintech.ru>; Saleem, Shiraz
> <shiraz.saleem@intel.com>; Jason Gunthorpe <jgg@ziepe.ca>; Leon
> Romanovsky <leon@kernel.org>; linux-rdma@vger.kernel.org; linux-
> kernel@vger.kernel.org; lvc-project@linuxtesting.org
> Subject: [PATCH] RDMA/irdma: Fix potential NULL-ptr-dereference
> 
> in_dev_get() can return NULL which will cause a failure once idev is
> dereferenced in in_dev_for_each_ifa_rtnl(). This patch adds a check for
> NULL value in idev beforehand.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 146b9756f14c ("RDMA/irdma: Add connection manager")
> Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
> 
>  drivers/infiniband/hw/irdma/cm.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/infiniband/hw/irdma/cm.c
> b/drivers/infiniband/hw/irdma/cm.c
> index 7b086fe63a24..195aa9ea18b6 100644
> --- a/drivers/infiniband/hw/irdma/cm.c
> +++ b/drivers/infiniband/hw/irdma/cm.c
> @@ -1722,6 +1722,9 @@ static int irdma_add_mqh_4(struct irdma_device
> *iwdev,
>  			continue;
> 
>  		idev = in_dev_get(ip_dev);
> +		if (!idev)
> +			continue;
> +
>  		in_dev_for_each_ifa_rtnl(ifa, idev) {
>  			ibdev_dbg(&iwdev->ibdev,
>  				  "CM: Allocating child CM Listener
> forIP=%pI4, vlan_id=%d, MAC=%pM\n",

Change looks good. Thanks!

Reviewed-by: Sindhu Devale <sindhu.devale@intel.com>

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

* Re: [PATCH] RDMA/irdma: Fix potential NULL-ptr-dereference
  2023-01-26 18:52 [PATCH] RDMA/irdma: Fix potential NULL-ptr-dereference Nikita Zhandarovich
  2023-01-27 15:38 ` Devale, Sindhu
@ 2023-01-29 12:57 ` Leon Romanovsky
  1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2023-01-29 12:57 UTC (permalink / raw)
  To: Mustafa Ismail, Nikita Zhandarovich
  Cc: Shiraz Saleem, Jason Gunthorpe, linux-rdma, linux-kernel, lvc-project


On Thu, 26 Jan 2023 10:52:30 -0800, Nikita Zhandarovich wrote:
> in_dev_get() can return NULL which will cause a failure once idev is
> dereferenced in in_dev_for_each_ifa_rtnl(). This patch adds a
> check for NULL value in idev beforehand.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 146b9756f14c ("RDMA/irdma: Add connection manager")
> Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
> 
> [...]

Applied, thanks!

[1/1] RDMA/irdma: Fix potential NULL-ptr-dereference
      https://git.kernel.org/rdma/rdma/c/5d9745cead1f12

Best regards,
-- 
Leon Romanovsky <leon@kernel.org>

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

end of thread, other threads:[~2023-01-29 12:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-26 18:52 [PATCH] RDMA/irdma: Fix potential NULL-ptr-dereference Nikita Zhandarovich
2023-01-27 15:38 ` Devale, Sindhu
2023-01-29 12:57 ` Leon Romanovsky

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