diff options
| author | Brian Ellis <brianellis@gotenna.com> | 2026-10-13 14:57:03 -0600 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2026-10-29 11:05:59 +0100 |
| commit | ea6cf69ad03c8d85138830c0d2c3b946b5ae231d (patch) | |
| tree | 980df45dcf8f380d56ee9fe2ebd6d014e1809bde /tools/perf/scripts/python/bin | |
| parent | 5b4b83c2ffe8740f6f3e54ea4d4962a62c063ef1 (diff) | |
usb: gadget: u_serial: fix NULL deref in gs_close() after failed open
gs_close() opens with
struct gs_port *port = tty->driver_data;
...
spin_lock_irq(&port->port_lock);
and never checks port. gs_open() assigns tty->driver_data only on the
port.count 0 -> 1 edge, so any failure earlier in gs_open() leaves it NULL,
and tty_open() calls tty_release(), and hence ->close(), when ->open()
fails.
syzbot hit exactly this on arm64. Fault injection failed the kfifo_alloc()
of the write buffer in gs_open():
__kfifo_alloc_node+0x10c/0x208 lib/kfifo.c:44
gs_open+0x144/0x514 drivers/usb/gadget/function/u_serial.c:636
tty_open+0x404/0x89c drivers/tty/tty_io.c:2137
and the tty core's close of the failed open then took port_lock through
the NULL port:
BUG: unable to handle kernel paging request in gs_close
KASAN: null-ptr-deref in range [0x00000000000003a0-0x00000000000003a7]
Call trace:
spin_lock_irq include/linux/spinlock.h:372 [inline]
gs_close+0xac/0x65c drivers/usb/gadget/function/u_serial.c:698
tty_release+0x2c4/0xffc drivers/tty/tty_io.c:1745
tty_open+0x46c/0x89c drivers/tty/tty_io.c:2146
Return early instead. There is nothing to release when the open never got
far enough to claim the port.
Unlike the check reverted by commit f6c7bc4a6823 ("Revert "usb: gadget:
u_serial: Add null pointer check in gs_start_io""), this is not hiding a
race: the tty core calls ->close() for an ->open() that failed by design,
so driver_data is legitimately unset on that path.
Fixes: c1dca562be8a ("usb gadget: split out serial core")
Reported-by: syzbot+782b2f1063e38ba8fa6e@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=782b2f1063e38ba8fa6e
Cc: stable <stable@kernel.org>
Assisted-by: LLM
Signed-off-by: Brian Ellis <brianellis@gotenna.com>
Link: https://patch.msgid.link/20261013-u_serial-gs-close-null-v4-1-9ea038501994@gotenna.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools/perf/scripts/python/bin')
0 files changed, 0 insertions, 0 deletions
