* [PATCH net] net: hso: fix use-after-free after failed tty open
@ 2026-12-01 10:13 Yannick Müller
2026-12-01 10:18 ` netdev-bot+sinfo
0 siblings, 1 reply; 3+ messages in thread
From: Yannick Müller @ 2026-12-01 10:13 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Johan Hovold, linux-usb, netdev, Yannick Müller
hso_serial_open() takes a reference to the serial device only if the
first open succeeds. The tty core, however, calls the cleanup()
operation after a failed open as well, and hso_serial_cleanup() drops a
reference whenever the driver data of the tty is set, which
hso_serial_open() does before it tries to start the device.
A first open that fails to start the device therefore drops the
reference taken at probe. The serial device is freed while its tty
device and its serial_table[] entry are still registered, and the next
open or the disconnect uses the freed memory.
Take the reference when the tty is bound to the serial device instead,
so that cleanup() always drops a reference that the tty holds.
The failed open has dropped one reference too many since the driver was
added. Commit 29bd3bc1194c ("hso: fix crash when device disappears
while serial port is open") only moved the final drop from close() to
cleanup().
Fixes: 72dc1c096c70 ("HSO: add option hso driver")
Cc: stable@vger.kernel.org
Signed-off-by: Yannick Müller <mail@ynnk.dev>
---
drivers/net/usb/hso.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 71caa3764b23..9d43e573d347 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -1250,7 +1250,11 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
hso_dbg(0x1, "Opening %d\n", serial->minor);
/* setup */
- tty->driver_data = serial;
+ if (tty->driver_data != serial) {
+ /* The tty holds a reference until hso_serial_cleanup(). */
+ kref_get(&serial->parent->ref);
+ tty->driver_data = serial;
+ }
tty_port_tty_set(&serial->port, tty);
/* check for port already opened, if not set the termios */
@@ -1265,8 +1269,6 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
if (result) {
hso_stop_serial_device(serial->parent);
serial->port.count--;
- } else {
- kref_get(&serial->parent->ref);
}
} else {
hso_dbg(0x1, "Port was already open\n");
base-commit: 19cc08c1a6a650f8e54c0461ff198be6448f425d
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: hso: fix use-after-free after failed tty open
2026-12-01 10:13 [PATCH net] net: hso: fix use-after-free after failed tty open Yannick Müller
@ 2026-12-01 10:18 ` netdev-bot+sinfo
[not found] ` <f261c2e9-6235-4564-ab6f-b05ec892d64b@me.com>
0 siblings, 1 reply; 3+ messages in thread
From: netdev-bot+sinfo @ 2026-12-01 10:18 UTC (permalink / raw)
To: Yannick Müller
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Johan Hovold, linux-usb, netdev
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: hso: fix use-after-free after failed tty open
[not found] ` <f261c2e9-6235-4564-ab6f-b05ec892d64b@me.com>
@ 2026-12-03 13:11 ` Johan Hovold
0 siblings, 0 replies; 3+ messages in thread
From: Johan Hovold @ 2026-12-03 13:11 UTC (permalink / raw)
To: Yannick Müller
Cc: netdev-bot+sinfo, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, linux-usb, netdev
On Tue, Dec 01, 2026 at 12:48:36PM +0000, Yannick Müller wrote:
> Hey all, The issue was found during a security review with AI support however the finding was manually confirmed. I wrote a working PoC and confirmed that the bug is trigerable at runtime using a real device. The kernel version which was beeing used is "7.3.7". Triggering it against the 7.3.7 kernel using KASAN resulted in the following dmesg trace: [ 62.333336] ================================================================== [ 62.333341] BUG: KASAN: slab-use-after-free in tty_init_dev.part.0+0x3d3/0x3f0 [ 62.333348] Write of size 8 at addr ffff88800374d120 by task reclaim_poc/1549 [ 62.333354] CPU: 0 UID: 0 PID: 1549 Comm: reclaim_poc Not tainted 7.3.7 #1 PREEMPT(lazy) [ 62.333358] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 [ 62.333361] Call Trace: [ 62.333362] <TASK> [ 62.333363] dump_stack_lvl+0x4e/0x70 [ 62.333368] print_report+0x157/0x4c9 [ 62.333372] ? __pfx__raw_spin_lock_irqsave+0x10/0x10 [ 62.333376] ? tty_ldisc_get.part.0+0xe1/0x2a0 [ 62.333380] ? tty_init_dev.part.0+0x3d3/0x3f0 [ 62.333383] kasan_report+0xce/0x100 [ 62.333387] ? tty_init_dev.part.0+0x3d3/0x3f0 [ 62.333390] tty_init_dev.part.0+0x3d3/0x3f0 [ 62.333393] tty_open+0x8f8/0x1180 [ 62.333396] ? __pfx_tty_open+0x10/0x10 [ 62.333398] ? __pfx_kobject_get_unless_zero+0x10/0x10 [ 62.333401] ? __pfx__raw_spin_lock+0x10/0x10 [ 62.333405] ? selinux_file_open+0x2f4/0x4a0 [ 62.333408] chrdev_open+0x1e5/0x5b0 [ 62.333411] ? __pfx_chrdev_open+0x10/0x10 [ 62.333414] ? __pfx_lockref_get+0x10/0x10 [ 62.333418] ? __pfx_chrdev_open+0x10/0x10 [ 62.333420] do_dentry_open+0x401/0x1280 [ 62.333424] vfs_open+0x74/0x350 [ 62.333427] path_openat+0x16b5/0x2020 [ 62.333430] ? __pfx_path_openat+0x10/0x10 [ 62.333433] do_file_open+0x1cd/0x400 [ 62.333436] ? __pfx_do_file_open+0x10/0x10 [ 62.333439] ? alloc_fd+0x32e/0x580 [ 62.333442] do_sys_openat2+0xe2/0x180 [ 62.333445] ? __pfx_do_sys_openat2+0x10/0x10 [ 62.333449] __x64_sys_openat+0x103/0x1d0 [ 62.333452] ? __pfx___x64_sys_openat+0x10/0x10 [ 62.333456] do_syscall_64+0xdf/0x4b0 [ 62.333459] entry_SYSCALL_64_after_hwframe+0x77/0x7f [ 62.333462] RIP: 0033:0x7fdd867e93a7 [ 62.333465] Code: 48 89 fa 4c 89 df e8 78 b3 00 00 8b 93 08 03 00 00 59 5e 48 83 f8 fc 74 1a 5b c3 0f 1f 84 00 00 00 00 00 48 8b 44 24 10 0f 05 <5b> c3 0f 1f 80 00 00 00 00 83 e2 39 83 fa 08 75 de e8 23 ff ff ff [ 62.333468] RSP: 002b:00007fffca637ab0 EFLAGS: 00000202 ORIG_RAX: 0000000000000101 [ 62.333472] RAX: ffffffffffffffda RBX: 00007fdd86757780 RCX: 00007fdd867e93a7 [ 62.333474] RDX: 0000000000000902 RSI: 000056281beeb004 RDI: ffffffffffffff9c [ 62.333476] RBP: 0000000000000002 R08: 0000000000000000 R09: 0000000000000000 [ 62.333478] R10: 0000000000000000 R11: 0000000000000202 R12: 000056281beeb01c [ 62.333479] R13: 000056281beed0c0 R14: 0000000000000040 R15: 000056281beeb004 [ 62.333482] </TASK> [ 62.333484] Allocated by task 1473: [ 62.333486] kasan_save_stack+0x30/0x50 [ 62.333489] kasan_save_track+0x14/0x30 [ 62.333491] __kasan_kmalloc+0x8f/0xa0 [ 62.333493] __kmalloc_noprof+0x1ae/0x460 [ 62.333497] load_elf_phdrs+0xd4/0x190 [ 62.333500] load_elf_binary+0x1dd/0x4700 [ 62.333503] bprm_execve+0x6c7/0x12c0 [ 62.333506] do_execveat_common.isra.0+0x3c4/0x540 [ 62.333508] __x64_sys_execve+0x8e/0xc0 [ 62.333510] do_syscall_64+0xdf/0x4b0 [ 62.333513] entry_SYSCALL_64_after_hwframe+0x77/0x7f [ 62.333516] Freed by task 1473: [ 62.333517] kasan_save_stack+0x30/0x50 [ 62.333519] kasan_save_track+0x14/0x30 [ 62.333522] kasan_save_free_info+0x3b/0x70 [ 62.333525] __kasan_slab_free+0x43/0x70 [ 62.333527] kfree+0x135/0x390 [ 62.333530] load_elf_binary+0x1834/0x4700 [ 62.333533] bprm_execve+0x6c7/0x12c0 [ 62.333536] do_execveat_common.isra.0+0x3c4/0x540 [ 62.333538] __x64_sys_execve+0x8e/0xc0 [ 62.333540] do_syscall_64+0xdf/0x4b0 [ 62.333542] entry_SYSCALL_64_after_hwframe+0x77/0x7f [ 62.333545] The buggy address belongs to the object at ffff88800374d000 which belongs to the cache kmalloc-1k of size 1024 [ 62.333548] The buggy address is located 288 bytes inside of freed 1024-byte region [ffff88800374d000, ffff88800374d400) [ 62.333551] The buggy address belongs to the physical page: [ 62.333553] page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x3748 [ 62.333556] head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0 [ 62.333558] flags: 0x100000000000040(head|node=0|zone=1) [ 62.333561] page_type: f5(slab) [ 62.333565] raw: 0100000000000040 ffff888001041dc0 dead000000000100 dead000000000122 [ 62.333567] raw: 0000000000000000 0000000000100010 00000000f5000000 0000000000000000 [ 62.333570] head: 0100000000000040 ffff888001041dc0 dead000000000100 dead000000000122 [ 62.333572] head: 0000000000000000 0000000000100010 00000000f5000000 0000000000000000 [ 62.333574] head: 0100000000000003 fffffffffffffe01 00000000ffffffff 00000000ffffffff [ 62.333576] head: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000 [ 62.333577] page dumped because: kasan: bad access detected [ 62.333579] Memory state around the buggy address: [ 62.333580] ffff88800374d000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [ 62.333582] ffff88800374d080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [ 62.333584] >ffff88800374d100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [ 62.333585] ^ [ 62.333586] ffff88800374d180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [ 62.333588] ffff88800374d200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb I also run the same PoC against a patched kernel containing my fix and it resolved the use-after-free issue. If you need more information please let me know! Thanks, Yannick Müller On Dec 1, 2026, at 11:18 AM, netdev-bot+sinfo@kernel.org wrote: Hi! This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information: - How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan. - Whether the issue was actually triggered, or is only theoretical (e.g. found by LLM and not proven at runtime). If it was triggered please include the symptoms, like the stack trace or kernel messages. Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. *IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages. -- The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
The mailing lists rejects HTML so this never made it to the list (and is
pretty unreadable for the rest of us as you can see above).
Johan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-03 13:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 10:13 [PATCH net] net: hso: fix use-after-free after failed tty open Yannick Müller
2026-12-01 10:18 ` netdev-bot+sinfo
[not found] ` <f261c2e9-6235-4564-ab6f-b05ec892d64b@me.com>
2026-12-03 13:11 ` Johan Hovold
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox