Re: [PATCH] USB: cdc-acm: refuse writes after disconnect
From: William A. Kennington III
Date: Sat Nov 21 2026 - 03:18:57 EST
On Fri, Nov 20, 2026 at 12:22:30PM +0100, Johan Hovold wrote:
> Thanks for reporting this. I assume this is not something you actually
> hit yourself but rather something flagged by an LLM?
We actually hit this twice in a kdump I got from a machine doing some
usb reset testing. An LLM was used to squash the bug.
Trimmed dmesg and backtrace from the first vmcore (the
second crash three days later hit the same PC/LR at 51s uptime):
[ 57.197371] usb 1-1.4.1: USB disconnect, device number 9
[ 58.287013] usb 1-1.1.1: new high-speed USB device number 15 using npcm7xx-ehci
[ 58.599405] usb 1-1.1.1: Product: Zephyr CDC ACM sample
[ 58.676523] cdc_acm 1-1.1.1:1.0: ttyACM1: USB ACM device
[ 58.797838] cdc_acm 1-1.2.1:1.0: ttyACM2: USB ACM device
[ 59.026611] cdc_acm 1-1.4.1:1.0: ttyACM3: USB ACM device
[ 59.324421] IPv6: ADDRCONF(NETDEV_CHANGE): mctpserial0: link becomes ready
[ 59.378147] Unable to handle kernel paging request at virtual address ffffffc009fd5000
...
[ 59.437892] Internal error: Oops: 0000000096000047 [#1] SMP
[ 59.446523] CPU: 1 PID: 217 Comm: kworker/1:2 Kdump: loaded Not tainted 5.15.167-yocto-s-dirty-4ae9335 #1
[ 59.456085] Hardware name: XXX
[ 59.462436] Workqueue: events mctp_serial_tx_work
[ 59.474127] pc : __memcpy+0x7c/0x240
[ 59.477711] lr : acm_tty_write+0xec/0x1fc
#10 [ffffff8001f03cd0] el1h_64_sync at ffffffc008011250
PC: ffffffc0083e94bc [memmove+124]
LR: ffffffc00859ed50 [acm_tty_write+236]
#11 [ffffff8001f03cf0] memmove at ffffffc0083e94b8
#12 [ffffff8001f03d60] mctp_serial_tx_work at ffffffc008559924
#13 [ffffff8001f03d90] process_one_work at ffffffc008059118
In both vmcores, tty ("ttyACM0") had count == 1, ldisc "mctp" attached,
acm->disconnected == true, and acm->wb[0].buf == 0xffffffc009fd5000
already unmapped by usb_free_coherent() in acm_disconnect().
> This isn't the right fix though as the line disciplines should not be
> calling back into the driver after a hangup (and this isn't cdc-acm
> specific).
>
> I've prepared a fix that restores the ldisc to N_TTY when a tty is
> reopened after a hangup instead.
Clearly your patch does it more cleanly :). Thanks for providing a clean
patch that looks like it does solve this issue
Thanks,
William