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-next>] [day] [month] [year] [list]
Date:   Fri, 21 Jul 2023 02:05:55 -0700
From:   Harshit Mogalapalli <harshit.m.mogalapalli@...cle.com>
To:     Vinod Koul <vkoul@...nel.org>,
        Kishon Vijay Abraham I <kishon@...nel.org>,
        Sergio Paracuellos <sergio.paracuellos@...il.com>,
        Heiko Stuebner <heiko@...ech.de>,
        Rob Herring <robh@...nel.org>,
        Marc Kleine-Budde <mkl@...gutronix.de>,
        Harshit Mogalapalli <harshit.m.mogalapalli@...cle.com>,
        David Yang <mmyangfl@...il.com>,
        Shawn Guo <shawn.guo@...aro.org>,
        Pengcheng Li <lpc.li@...ilicon.com>,
        Jiancheng Xue <xuejiancheng@...ilicon.com>,
        linux-phy@...ts.infradead.org, linux-kernel@...r.kernel.org
Cc:     dan.carpenter@...aro.org, christophe.jaillet@...adoo.fr,
        julia.lawall@...ia.fr, kernel-janitors@...r.kernel.org,
        error27@...il.com
Subject: [PATCH] phy: hisilicon: Fix an out of bounds check in hisi_inno_phy_probe()

The size of array 'priv->ports[]' is INNO_PHY_PORT_NUM.

In the for loop, 'i' is used as the index for array 'priv->ports[]'
with a check (i > INNO_PHY_PORT_NUM) which indicates that
INNO_PHY_PORT_NUM is allowed value for 'i' in the same loop.

This > comparison needs to be changed to >=, otherwise it potentially leads
to an out of bounds write on the next iteration through the loop

Fixes: ba8b0ee81fbb ("phy: add inno-usb2-phy driver for hi3798cv200 SoC")
Reported-by: Dan Carpenter <dan.carpenter@...aro.org>
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@...cle.com>
---
This is purely based on static analysis, only compile tested.

Inspired based on a patch from Christophe Jaillet:
https://lore.kernel.org/all/cd01cba1c7eda58bdabaae174c78c067325803d2.1689803636.git.christophe.jaillet@wanadoo.fr/
---
 drivers/phy/hisilicon/phy-hisi-inno-usb2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/phy/hisilicon/phy-hisi-inno-usb2.c b/drivers/phy/hisilicon/phy-hisi-inno-usb2.c
index 498afd81696b..c138cd4807d6 100644
--- a/drivers/phy/hisilicon/phy-hisi-inno-usb2.c
+++ b/drivers/phy/hisilicon/phy-hisi-inno-usb2.c
@@ -185,7 +185,7 @@ static int hisi_inno_phy_probe(struct platform_device *pdev)
 		phy_set_drvdata(phy, &priv->ports[i]);
 		i++;
 
-		if (i > INNO_PHY_PORT_NUM) {
+		if (i >= INNO_PHY_PORT_NUM) {
 			dev_warn(dev, "Support %d ports in maximum\n", i);
 			of_node_put(child);
 			break;
-- 
2.39.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ