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]
Message-ID: <20240328091021.18027-1-amishin@t-argos.ru>
Date: Thu, 28 Mar 2024 12:10:21 +0300
From: Aleksandr Mishin <amishin@...rgos.ru>
To: Keerthy <j-keerthy@...com>
CC: Aleksandr Mishin <amishin@...rgos.ru>, Linus Walleij
	<linus.walleij@...aro.org>, Bartosz Golaszewski <brgl@...ev.pl>, "Andrew F.
 Davis" <afd@...com>, <linux-gpio@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>, <lvc-project@...uxtesting.org>
Subject: [PATCH] gpio: davinci: Fix potential buffer overflow

In davinci_gpio_probe() accessing an element of array 'chips->regs' of size 5 and
array 'offset_array' of size 5 can lead to a buffer overflow, since the index
'bank' can have an out of range value 63.
Fix this bug by limiting top index value.

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

Fixes: c809e37a3b5a ("gpio: davinci: Allocate the correct amount of memory for controller")
Signed-off-by: Aleksandr Mishin <amishin@...rgos.ru>
---
 drivers/gpio/gpio-davinci.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index bb499e362912..b65df1f2b83f 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -257,6 +257,9 @@ static int davinci_gpio_probe(struct platform_device *pdev)
 	spin_lock_init(&chips->lock);
 
 	nbank = DIV_ROUND_UP(ngpio, 32);
+    if (nbank > MAX_REGS_BANKS || nbank > 5) {
+        nbank = MAX_REGS_BANKS < 5 ? MAX_REGS_BANKS : 5;
+	}
 	for (bank = 0; bank < nbank; bank++)
 		chips->regs[bank] = gpio_base + offset_array[bank];
 
-- 
2.30.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ