Thread View: linux.kernel.netdev
2 messages
2 total messages
Started by Yannick Müller
Tue, 01 Dec 2026 10:13
[PATCH net] net: hso: fix use-after-free after failed tty open
Author: Yannick Müller
Date: Tue, 01 Dec 2026 10:13
Date: Tue, 01 Dec 2026 10:13
57 lines
13382 bytes
13382 bytes
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
Re: [PATCH net] net: hso: fix use-after-free after failed tty open
Author: netdev-bot+sinfo
Date: Tue, 01 Dec 2026 10:18
Date: Tue, 01 Dec 2026 10:18
23 lines
8625 bytes
8625 bytes
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.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads