linux/drivers/usb
HyeongJun An 0a57320f71 USB: serial: kl5kusb105: fix bulk-out buffer overflow
commit 96d47e40bf upstream.

klsi_105_prepare_write_buffer() is called by the generic write path
with the bulk-out buffer and its size (bulk_out_size, 64 bytes). It
stores a two-byte length header at the start of the buffer and copies
the payload from the write fifo starting at buf + KLSI_HDR_LEN, but
passes the full buffer size as the number of bytes to copy:

  count = kfifo_out_locked(&port->write_fifo, buf + KLSI_HDR_LEN,
                           size, &port->lock);

When the fifo holds at least size bytes, size bytes are copied starting
two bytes into the size-byte buffer, writing KLSI_HDR_LEN bytes past its
end. Copy at most size - KLSI_HDR_LEN bytes instead, leaving room for
the header as safe_serial already does.

Writing bulk_out_size or more bytes to the tty triggers a slab
out-of-bounds write, observed with KASAN by emulating the device with
dummy_hcd and raw-gadget:

  BUG: KASAN: slab-out-of-bounds in kfifo_copy_out+0x83/0xc0
  Write of size 64 at addr ffff888112c62202 by task python3
   kfifo_copy_out
   klsi_105_prepare_write_buffer [kl5kusb105]
   usb_serial_generic_write_start [usbserial]
  Allocated by task 139:
   usb_serial_probe [usbserial]
  The buggy address is located 2 bytes inside of allocated 64-byte region

The out-of-bounds write no longer occurs with this change applied.

Fixes: 60b3013cda ("USB: kl5usb105: reimplement using generic framework")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: HyeongJun An <sammiee5311@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-06-19 13:33:36 +02:00
..
atm usb: atm: cxacru: Merge cxacru_upload_firmware() into cxacru_heavy_init() 2025-08-28 16:24:27 +02:00
c67x00 usb/c67x00: Replace tasklet with work 2021-01-26 18:36:37 +01:00
cdns3 usb: cdns3: plat: fix unbalanced pm_runtime_forbid() call permanently leaks the runtime PM usage counter across bind/unbind cycles 2026-06-19 13:33:27 +02:00
chipidea usb: chipidea: core: convert ci_role_switch to local variable 2026-06-19 13:33:29 +02:00
class usb: usbtmc: reject interrupt endpoints with small wMaxPacketSize 2026-06-19 13:33:30 +02:00
common usb: ulpi: fix memory leak on ulpi_register() error paths 2026-06-01 17:35:20 +02:00
core usb: core: Fix SuperSpeed root hub wMaxPacketSize 2026-06-19 13:33:32 +02:00
dwc2 usb: dwc2: Fix use after free in debug code 2026-06-19 13:33:27 +02:00
dwc3 usb: dwc3: Check for USB4 IP_NAME 2026-02-06 16:41:48 +01:00
early usb: early: xhci-dbc: Fix early_ioremap leak 2025-08-28 16:24:06 +02:00
gadget usb: gadget: f_fs: copy only received bytes on short ep0 read 2026-06-19 13:33:30 +02:00
host xhci: tegra: Fix ghost USB device on dual-role port unplug 2026-06-19 13:33:32 +02:00
image usb: image: mdc800: kill download URB on timeout 2026-04-18 10:33:14 +02:00
isp1760 usb: isp1760: Fix out-of-bounds array access 2022-06-09 10:22:27 +02:00
misc usb: misc: uss720: properly clean up reference in uss720_probe() 2026-04-18 10:33:13 +02:00
mon usb: mon: Increase BUFF_MAX to 64 MiB to support multi-MB URBs 2025-12-07 06:09:22 +09:00
mtu3 usb: mtu3: fix kernel panic at qmu transfer done irq handler 2023-05-11 23:00:33 +09:00
musb usb: musb: omap2430: fix device leak at unbind 2025-08-28 16:24:32 +02:00
phy usb: phy: isp1301: fix non-OF device reference imbalance 2026-01-19 13:09:50 +01:00
renesas_usbhs usb: renesas_usbhs: fix use-after-free in ISR during device removal 2026-04-18 10:33:14 +02:00
roles usb: roles: set switch registered flag early on 2025-03-13 12:50:37 +01:00
serial USB: serial: kl5kusb105: fix bulk-out buffer overflow 2026-06-19 13:33:36 +02:00
storage usb: storage: Add quirks for PNY Elite Portable SSD 2026-06-19 13:33:29 +02:00
typec usb: typec: wcove: don't write past struct pd_message in wcove_read_rx_buffer() 2026-06-19 13:33:26 +02:00
usbip usbip: vudc: Fix use after free bug in vudc_remove due to race condition 2026-06-19 13:33:30 +02:00
Kconfig usb: remove reference to deleted config STB03xxx 2021-08-18 15:32:19 +02:00
Makefile usb: host: remove line for obsolete config USB_HWA_HCD 2021-08-18 15:32:19 +02:00
usb-skeleton.c USB: usb-skeleton: drop redundant in-urb check 2019-10-10 12:41:19 +02:00