lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251006124258.1132312-1-Pavel.Zhigulin@kaspersky.com>
Date: Mon, 6 Oct 2025 15:42:57 +0300
From: Pavel Zhigulin <Pavel.Zhigulin@...persky.com>
To: Peter Ujfalusi <peter.ujfalusi@...il.com>
CC: Pavel Zhigulin <Pavel.Zhigulin@...persky.com>, Vinod Koul
	<vkoul@...nel.org>, Grygorii Strashko <grygorii.strashko@...com>,
	<dmaengine@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: [PATCH v2] dma: k3-udma - fix potential null dereference in k3_udma_glue_request_rx_chn_priv()

In function k3_udma_glue_request_rx_chn_priv(), the pointer rx_chn->flows,
after being compared to NULL, is passed to k3_udma_glue_release_rx_chn(),
where it is dereferenced unconditionally after being passed to
k3_udma_glue_release_rx_flow() in a for loop. This happens because
rx_chn->flow_num is set before successful allocation.

This fix sets rx_chn->flow_num only after rx_chn->flows is successfully
allocated, preventing the for loop from running if allocation fails.

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

Fixes: d70241913413 ("dmaengine: ti: k3-udma: Add glue layer for non DMAengine users")
Signed-off-by: Pavel Zhigulin <Pavel.Zhigulin@...persky.com>
---
v2: Fix passing uninitialized rx_chn->flow_num to devm_kcalloc. Add
proper subject to patch.

 drivers/dma/ti/k3-udma-glue.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/ti/k3-udma-glue.c b/drivers/dma/ti/k3-udma-glue.c
index f87d244cc2d6..03679f61c241 100644
--- a/drivers/dma/ti/k3-udma-glue.c
+++ b/drivers/dma/ti/k3-udma-glue.c
@@ -1031,15 +1031,15 @@ k3_udma_glue_request_rx_chn_priv(struct device *dev, const char *name,
 			rx_chn->flow_id_base = rx_chn->udma_rchan_id;
 	}

-	rx_chn->flow_num = cfg->flow_id_num;
-
-	rx_chn->flows = devm_kcalloc(dev, rx_chn->flow_num,
+	rx_chn->flows = devm_kcalloc(dev, cfg->flow_id_num,
 				     sizeof(*rx_chn->flows), GFP_KERNEL);
 	if (!rx_chn->flows) {
 		ret = -ENOMEM;
 		goto err;
 	}

+	rx_chn->flow_num = cfg->flow_id_num;
+
 	ret = k3_udma_glue_allocate_rx_flows(rx_chn, cfg);
 	if (ret)
 		goto err;
--
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ