All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] USB: serial: whiteheat: fix slab corruption and endianness bug
@ 2019-10-29 10:23 Johan Hovold
  2019-10-29 10:23 ` [PATCH 1/2] USB: serial: whiteheat: fix potential slab corruption Johan Hovold
  2019-10-29 10:23 ` [PATCH 2/2] USB: serial: whiteheat: fix line-speed endianness Johan Hovold
  0 siblings, 2 replies; 3+ messages in thread
From: Johan Hovold @ 2019-10-29 10:23 UTC (permalink / raw)
  To: Johan Hovold, Greg Kroah-Hartman; +Cc: linux-usb

These patches fix a user-controlled slab buffer corruption, and adds a
missing endianess conversion when setting the line speed.

Greg, feel free to pick up the first one directly if you want.

Johan


Johan Hovold (2):
  USB: serial: whiteheat: fix potential slab corruption
  USB: serial: whiteheat: fix line-speed endianness

 drivers/usb/serial/whiteheat.c | 13 ++++++++++---
 drivers/usb/serial/whiteheat.h |  2 +-
 2 files changed, 11 insertions(+), 4 deletions(-)

-- 
2.23.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] USB: serial: whiteheat: fix potential slab corruption
  2019-10-29 10:23 [PATCH 0/2] USB: serial: whiteheat: fix slab corruption and endianness bug Johan Hovold
@ 2019-10-29 10:23 ` Johan Hovold
  2019-10-29 10:23 ` [PATCH 2/2] USB: serial: whiteheat: fix line-speed endianness Johan Hovold
  1 sibling, 0 replies; 3+ messages in thread
From: Johan Hovold @ 2019-10-29 10:23 UTC (permalink / raw)
  To: Johan Hovold, Greg Kroah-Hartman; +Cc: linux-usb, stable

Fix a user-controlled slab buffer overflow due to a missing sanity check
on the bulk-out transfer buffer used for control requests.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/serial/whiteheat.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 79314d8c94a4..76cabcb30d21 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -559,6 +559,10 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command,
 
 	command_port = port->serial->port[COMMAND_PORT];
 	command_info = usb_get_serial_port_data(command_port);
+
+	if (command_port->bulk_out_size < datasize + 1)
+		return -EIO;
+
 	mutex_lock(&command_info->mutex);
 	command_info->command_finished = false;
 
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] USB: serial: whiteheat: fix line-speed endianness
  2019-10-29 10:23 [PATCH 0/2] USB: serial: whiteheat: fix slab corruption and endianness bug Johan Hovold
  2019-10-29 10:23 ` [PATCH 1/2] USB: serial: whiteheat: fix potential slab corruption Johan Hovold
@ 2019-10-29 10:23 ` Johan Hovold
  1 sibling, 0 replies; 3+ messages in thread
From: Johan Hovold @ 2019-10-29 10:23 UTC (permalink / raw)
  To: Johan Hovold, Greg Kroah-Hartman; +Cc: linux-usb

Add missing endianness conversion when setting the line speed so that
this driver might work also on big-endian machines.

Also use an unsigned format specifier in the corresponding debug
message.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/serial/whiteheat.c | 9 ++++++---
 drivers/usb/serial/whiteheat.h | 2 +-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 76cabcb30d21..ca3bd58f2025 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -636,6 +636,7 @@ static void firm_setup_port(struct tty_struct *tty)
 	struct device *dev = &port->dev;
 	struct whiteheat_port_settings port_settings;
 	unsigned int cflag = tty->termios.c_cflag;
+	speed_t baud;
 
 	port_settings.port = port->port_number + 1;
 
@@ -696,11 +697,13 @@ static void firm_setup_port(struct tty_struct *tty)
 	dev_dbg(dev, "%s - XON = %2x, XOFF = %2x\n", __func__, port_settings.xon, port_settings.xoff);
 
 	/* get the baud rate wanted */
-	port_settings.baud = tty_get_baud_rate(tty);
-	dev_dbg(dev, "%s - baud rate = %d\n", __func__, port_settings.baud);
+	baud = tty_get_baud_rate(tty);
+	port_settings.baud = cpu_to_le32(baud);
+	dev_dbg(dev, "%s - baud rate = %u\n", __func__, baud);
 
 	/* fixme: should set validated settings */
-	tty_encode_baud_rate(tty, port_settings.baud, port_settings.baud);
+	tty_encode_baud_rate(tty, baud, baud);
+
 	/* handle any settings that aren't specified in the tty structure */
 	port_settings.lloop = 0;
 
diff --git a/drivers/usb/serial/whiteheat.h b/drivers/usb/serial/whiteheat.h
index 00398149cd8d..269e727a92f9 100644
--- a/drivers/usb/serial/whiteheat.h
+++ b/drivers/usb/serial/whiteheat.h
@@ -87,7 +87,7 @@ struct whiteheat_simple {
 
 struct whiteheat_port_settings {
 	__u8	port;		/* port number (1 to N) */
-	__u32	baud;		/* any value 7 - 460800, firmware calculates
+	__le32	baud;		/* any value 7 - 460800, firmware calculates
 				   best fit; arrives little endian */
 	__u8	bits;		/* 5, 6, 7, or 8 */
 	__u8	stop;		/* 1 or 2, default 1 (2 = 1.5 if bits = 5) */
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-10-29 10:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-29 10:23 [PATCH 0/2] USB: serial: whiteheat: fix slab corruption and endianness bug Johan Hovold
2019-10-29 10:23 ` [PATCH 1/2] USB: serial: whiteheat: fix potential slab corruption Johan Hovold
2019-10-29 10:23 ` [PATCH 2/2] USB: serial: whiteheat: fix line-speed endianness Johan Hovold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.