Skip to contentSkip to conversation

ibmtr: possible Read buffer overflow?

PATCH Applied Roel Kluin 2 participants 2 messages Oct 3, 2009 – Oct 30, 2009

Subsystems (2)
lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 ibmtr: possible Read buffer overflow?

Prevent read outside array bounds.

---
Is this maybe required?

build tested

drivers/net/tokenring/ibmtr.c +9 -2
index 525bbc5..6a3c751 100644
@@ -1143,9 +1143,16 @@ static void dir_open_adapter (struct net_device *dev)
                 } else {
 			char **prphase = printphase;
 			char **prerror = printerror;
+			int pnr = err / 16 - 1;
+			int enr = err % 16 - 1;
 			DPRINTK("TR Adapter misc open failure, error code = ");
-			printk("0x%x, Phase: %s, Error: %s\n",
-				err, prphase[err/16 -1], prerror[err%16 -1]);
+			if (pnr < 0 || pnr >= ARRAY_SIZE(printphase) ||
+					enr < 0 ||
+					enr >= ARRAY_SIZE(printerror))
+				printk("0x%x, invalid Phase/Error.", err);
+			else
+				printk("0x%x, Phase: %s, Error: %s\n", err,
+						prphase[pnr], prerror[enr]);
 			printk(" retrying after %ds delay...\n",
 					TR_RETRY_INTERVAL/HZ);
                 }
maintainer Applied
#1 lore raw

From: Roel Kluin <[email protected]>
Date: Sat, 03 Oct 2009 23:26:55 +0200

Quoted 5 lines

Prevent read outside array bounds.

---
Is this maybe required?

I can't see anything that protects against this, so yes it seems to be required.

Applied to net-2.6, thanks.