From: sashiko-bot@kernel.org
To: "Yannick Müller" <mail@ynnk.dev>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH net] net: hso: fix use-after-free after failed tty open
Date: Wed, 02 Dec 2026 10:15:16 +0000 [thread overview]
Message-ID: <sashiko-outbox-245409@kernel.org> (raw)
In-Reply-To: <20261201101336.164922-1-mail@ynnk.dev>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] net: usb: hso: active serial URBs not killed in
hso_free_interface() [1]
--
commit 6069581307322cf466dfc112f9e4e7a8b3902bd1
Author: Yannick Müller <mail@ynnk.dev>
net: hso: fix use-after-free after failed tty open
This commit takes the serial device reference when binding tty->driver_data
in hso_serial_open() rather than after hso_start_serial_device() succeeds,
so that a failed initial open does not drop the probe reference in
hso_serial_cleanup().
> diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
> index 71caa3764b239..9d43e573d3478 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");
[Severity: Critical]
This problem wasn't introduced by this patch, but can disconnecting an open
serial port leave in-flight URBs active when the final reference is dropped in
hso_serial_cleanup() [1]?
When an interface is torn down while a serial port is open,
hso_free_interface() sets serial->parent->usb_gone = 1 and drops the probe
reference without calling hso_stop_serial_device():
drivers/net/usb/hso.c:hso_free_interface() {
...
serial = dev2ser(serial_table[i]);
tty_port_tty_hangup(&serial->port, false);
mutex_lock(&serial->parent->mutex);
serial->parent->usb_gone = 1;
mutex_unlock(&serial->parent->mutex);
cancel_work_sync(&serial_table[i]->async_put_intf);
cancel_work_sync(&serial_table[i]->async_get_intf);
hso_serial_tty_unregister(serial);
kref_put(&serial->parent->ref, hso_serial_ref_free);
...
}
When userspace then closes the hung-up TTY, hso_serial_close() sees usb_gone
set and skips hso_stop_serial_device():
drivers/net/usb/hso.c:hso_serial_close() {
...
if (serial->port.count <= 0) {
serial->port.count = 0;
tty_port_tty_set(&serial->port, NULL);
if (!usb_gone)
hso_stop_serial_device(serial->parent);
tasklet_kill(&serial->unthrottle_tasklet);
}
...
}
hso_serial_cleanup() then drops the final serial->parent->ref, and
hso_free_serial_device() and hso_free_shared_int() call usb_free_urb() and
kfree() on active URBs and transfer buffers that were never killed via
usb_kill_urb(), triggering a WARN_ON in usb_free_urb() and a use-after-free
when those URBs complete.
[1] https://sashiko.dev/#/bug/linux-138610c9-94b5-4a04-b8c0-02e4a533d28f
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201101336.164922-1-mail@ynnk.dev?part=1
prev parent reply other threads:[~2026-12-02 10:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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
2026-12-02 10:15 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-245409@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mail@ynnk.dev \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.