Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH] USB: serial: cypress_m8: fix memory corruption with small endpoint
@ 2026-05-22 10:16 Johan Hovold
  2026-05-22 11:35 ` Greg Kroah-Hartman
  2026-05-22 14:16 ` Cen Zhang
  0 siblings, 2 replies; 5+ messages in thread
From: Johan Hovold @ 2026-05-22 10:16 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Greg Kroah-Hartman, Zhang Cen, linux-usb, linux-kernel, stable

Make sure that the interrupt-out endpoint max packet size is at least
eight bytes to avoid user-controlled slab corruption or NULL-pointer
dereference should a malicious device report a smaller size.

Fixes: 3416eaa1f8f8 ("USB: cypress_m8: Packet format is separate from characteristic size")
Cc: stable@vger.kernel.org	# 2.6.26
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/serial/cypress_m8.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index afff1a0f4298..82ba0900b399 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -445,6 +445,14 @@ static int cypress_generic_port_probe(struct usb_serial_port *port)
 		return -ENODEV;
 	}
 
+	/*
+	 * The buffer must be large enough for the one or two-byte header (and
+	 * following data) but assume anything smaller than eight bytes is
+	 * broken.
+	 */
+	if (port->interrupt_out_size < 8)
+		return -EINVAL;
+
 	priv = kzalloc_obj(struct cypress_private);
 	if (!priv)
 		return -ENOMEM;
-- 
2.53.0


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

end of thread, other threads:[~2026-05-22 14:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-22 10:16 [PATCH] USB: serial: cypress_m8: fix memory corruption with small endpoint Johan Hovold
2026-05-22 11:35 ` Greg Kroah-Hartman
2026-05-22 14:16 ` Cen Zhang
2026-05-22 14:28   ` Johan Hovold
2026-05-22 14:42     ` Cen Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox