Skip to contentSkip to conversation

drivers/usb/serial/mos*: prevent reading uninitialized stack memory

PATCH In review Dan Rosenberg 2 participants 2 messages Sep 15, 2010 – Sep 16, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/usb/serial/mos*: prevent reading uninitialized stack memory

The TIOCGICOUNT device ioctl in both mos7720.c and mos7840.c allows unprivileged users to read uninitialized stack memory, because the "reserved" member of the serial_icounter_struct struct declared on the stack is not altered or zeroed before being copied back to the user. This patch takes care of it.

drivers/usb/serial/mos7720.c +3 -0
diff -urp linux-2.6.35.4.orig/drivers/usb/serial/mos7720.c linux-2.6.35.4/drivers/usb/serial/mos7720.c
@@ -2024,6 +2024,9 @@ static int mos7720_ioctl(struct tty_stru
 
 	case TIOCGICOUNT:
 		cnow = mos7720_port->icount;
+
+		memset(&icount, 0, sizeof(struct serial_icounter_struct));
+
 		icount.cts = cnow.cts;
 		icount.dsr = cnow.dsr;
 		icount.rng = cnow.rng;
drivers/usb/serial/mos7840.c +3 -0
diff -urp linux-2.6.35.4.orig/drivers/usb/serial/mos7840.c linux-2.6.35.4/drivers/usb/serial/mos7840.c
@@ -2273,6 +2273,9 @@ static int mos7840_ioctl(struct tty_stru
 	case TIOCGICOUNT:
 		cnow = mos7840_port->icount;
 		smp_rmb();
+
+		memset(&icount, 0, sizeof(struct serial_icounter_struct));
+
 		icount.cts = cnow.cts;
 		icount.dsr = cnow.dsr;
 		icount.rng = cnow.rng;
#1 lore raw
Quoted 5 lines · On Wed, 15 Sep 2010 17:44:16 -0400 Dan Rosenberg <[email protected]>…

The TIOCGICOUNT device ioctl in both mos7720.c and mos7840.c allows unprivileged users to read uninitialized stack memory, because the "reserved" member of the serial_icounter_struct struct declared on the stack is not altered or zeroed before being copied back to the user. This patch takes care of it.

ACK ... but this is the wrong way to fix these. We'll be squashing new ones between here and eternity if we just stick memsets in. It wants making a tty operation off the tty ioctl code so that there is one place that clears it and copies it to the user.

I'll have a look at what is needed - I don't think very much.

Alan