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>] [day] [month] [year] [list]
Message-ID: <48076145.1080906@tiscali.nl>
Date:	Thu, 17 Apr 2008 16:40:05 +0200
From:	Roel Kluin <12o3l@...cali.nl>
To:	romieu@...zoreil.com
CC:	netdev@...r.kernel.org, lkml <linux-kernel@...r.kernel.org>
Subject: [PATCH] NET: r8169: fix past rtl_chip_info arraysize for unknown
 chipsets

i is unsigned, so, with an unknown chip, for (;i >= 0;) fails and i
just keeps decrementing, underflowing past ARRAY_SIZE(rtl_chip_info).

Signed-off-by: Roel Kluin <12o3l@...cali.nl>
---
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 3acfeea..7d6be1b 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -1702,21 +1702,19 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	/* Identify chip attached to board */
 	rtl8169_get_mac_version(tp, ioaddr);
-
 	rtl8169_print_mac_version(tp);
 
-	for (i = ARRAY_SIZE(rtl_chip_info) - 1; i >= 0; i--) {
-		if (tp->mac_version == rtl_chip_info[i].mac_version)
+	for (i = ARRAY_SIZE(rtl_chip_info) - 1;
+			tp->mac_version != rtl_chip_info[i].mac_version; i--) {
+		if (i == 0) {
+			/* Unknown chip: assume chipset 0: original RTL-8169 */
+			if (netif_msg_probe(tp)) {
+				dev_printk(KERN_DEBUG, &pdev->dev,
+					"unknown chip version, assuming %s\n",
+					rtl_chip_info[0].name);
+			}
 			break;
-	}
-	if (i < 0) {
-		/* Unknown chip: assume array element #0, original RTL-8169 */
-		if (netif_msg_probe(tp)) {
-			dev_printk(KERN_DEBUG, &pdev->dev,
-				"unknown chip version, assuming %s\n",
-				rtl_chip_info[0].name);
 		}
-		i++;
 	}
 	tp->chipset = i;
 
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ