drivers/usb/serial/mos*: prevent reading uninitialized stack memory
Subsystems (2)
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
@@ -2024,6 +2024,9 @@ static int mos7720_ioctl(struct tty_strucase 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
@@ -2273,6 +2273,9 @@ static int mos7840_ioctl(struct tty_strucase 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;
Quoted 5 lines · On Wed, 15 Sep 2010 17:44:16 -0400 Dan Rosenberg <[email protected]>…
The TIOCGICOUNT device ioctl in both
mos7720.candmos7840.callows unprivileged users to read uninitialized stack memory, because the "reserved" member of theserial_icounter_structstruct 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