summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python/bin
diff options
context:
space:
mode:
authorKrystian Kaniewski <krystianmkaniewski@gmail.com>2026-10-22 11:13:59 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-10-29 11:11:45 +0100
commit1981b53c2b52a00f0f4b9eb87183c9aedc8dac5d (patch)
tree7ca4756559458f6a8d1e1af3fa650e2dcbd91020 /tools/perf/scripts/python/bin
parent03e3c33fe074ba57ae4457894fe5b6a90e3be6ee (diff)
usb: gadget: u_serial: pin ports while TTYs are installed
A slab-use-after-free can occur when gserial_free_line() frees struct gs_port while it is still reachable through an installed TTY. The port->port.count value tracks successful opens, but it is zero before gs_open() and again after gs_close(), before TTY cleanup has finished. Teardown can therefore free gs_port while tty_init_dev() or release_tty() still accesses its tty_port. Manage gs_port lifetime with tty_port references. Take a reference in gs_install(), drop it in gs_cleanup(), and move the final free to gs_port_destruct(). Unregister the TTY device before dropping the owner reference. Keep each minor reserved until the old port is destroyed so an installed TTY for one generation cannot overlap a replacement at the same minor. Publish the new port before device registration so the cdev and add uevent never expose a TTY before gs_install() can pin it. Since commit 8df07fe93573 ("tty: fix saved termios reset race"), u_serial registration no longer frees saved termios. On registration failure, unpublish the port before dropping its owner reference. Check in gs_open() that the installed port is still the published generation. Track failures after a successful install so close callbacks issued by the TTY core do not decrement port->port.count for opens that never incremented it. Fixes: 19b10a8828a6 ("usb: gadget: allocate & giveback serial ports instead hard code them") Assisted-by: Gemini:gemini-3.8-flash syzbot Reported-by: syzbot+fe63e4d633540f230624@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=fe63e4d633540f230624 Link: https://syzkaller.appspot.com/ai_job?id=ec789387-2e7b-4a8f-a7a1-a47bf7fa57f5 Cc: stable <stable@kernel.org> Signed-off-by: Krystian Kaniewski <krystianmkaniewski@gmail.com> Tested-by: syzbot@syzkaller.appspotmail.com Tested-by: Mehmet Fide <mehmet.fide@screeningeagle.com> Reported-by: syzbot+bca09f5d8b843bbf7571@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=bca09f5d8b843bbf7571 Link: https://patch.msgid.link/20261022091359.1187468-1-krystianmkaniewski@gmail.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