Commit e7b931be authored by Johan Hovold's avatar Johan Hovold

USB: serial: iuu_phoenix: fix memory corruption

The driver would happily overwrite its write buffer with user data in
256 byte increments due to a removed buffer-space sanity check.

Fixes: 5fcf62b0 ("tty: iuu_phoenix: fix locking.")
Cc: stable <stable@vger.kernel.org>     # 2.6.31
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parent da6902e5
...@@ -697,14 +697,16 @@ static int iuu_uart_write(struct tty_struct *tty, struct usb_serial_port *port, ...@@ -697,14 +697,16 @@ static int iuu_uart_write(struct tty_struct *tty, struct usb_serial_port *port,
struct iuu_private *priv = usb_get_serial_port_data(port); struct iuu_private *priv = usb_get_serial_port_data(port);
unsigned long flags; unsigned long flags;
if (count > 256)
return -ENOMEM;
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
count = min(count, 256 - priv->writelen);
if (count == 0)
goto out;
/* fill the buffer */ /* fill the buffer */
memcpy(priv->writebuf + priv->writelen, buf, count); memcpy(priv->writebuf + priv->writelen, buf, count);
priv->writelen += count; priv->writelen += count;
out:
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
return count; return count;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment