From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796206517; b=cIRrr4Zbe5Jp8ovm5SiC8I9R8ZA4DX37dXg0ziw9+tESI7FgC6iu1OToBc2gbBN7ICtc RhEuUMhVEhG9Erl+4Sss/7DNKnozzsUZTfiRzNQzlzLQ7Hspa8604tgYxjTJjlO9xmLNV PXBzB5a4cj2WGtY6Ee70Jgn+AeT0jPNTTxwPTSSB6t3t9P7RIHEhDPeUfDzUxDHb6BJs4 3KPS+EKhNTURRe+jkzLe1DnJLmRHk6/4ljOJ/Y917CdKQ5mN6XRiYEyaqxwXkE14Pv73y oB+d8KIHyuyGt8KNJMpCXXPnk7Q1nAPYq5liFUWYOGURnBiaAHP9+7erT7DCVb92dAw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796206517; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=n0Nc/GWe5UX2ppVs4T1safe3OfwwY82vQbFOCsF1knA=; b=TPriQNDahg2bCXTGLTxDhtqAPH8fcJNGqyk2zx9jSuxlwaqioc8n6iGa6baEmhb5Guhd vRFEkbR6Xunp/NZVCNHsp5fzbdOa93WdQcd+bTX8iOEmxHZREmq+OPcJT0AhafTyxQuPJ OynRvwPtia/1enKtMrYEqdpnWbNd8YOOHDMs/fdzrWMvls0sU2YftdaKvuNgTMqzsiOY3 jV3AFpTeRzBAC1wjAoJ+SmBsx/5yl9MceER8LUB3X8MFZ8Sk7qsQsYPoJFAQ+RO1+BWXK p9Pny9B/iNBrXtpaRPEb+K9OPBvPWP3mmAq+g3OgnQTLZDzMU9hQByioYfD5vV1meQA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DDnRxZQN; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7151A606A68A for ; Wed, 2 Dec 2026 10:15:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DDnRxZQN Received: by smtp.kernel.org (Postfix) with ESMTPSA id F17A71F00925; Wed, 2 Dec 2026 10:15:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796206517; bh=n0Nc/GWe5UX2ppVs4T1safe3OfwwY82vQbFOCsF1knA=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=DDnRxZQN1Rces6z6Bq/CGAJhvjj5dCOG91jVsHO2jxFimoZVGO9br+T0mxpy7Y/pT Tjm+LmU5b/zkfwW9VfMQmkdqAWpJLAJ6SRNn/OkQOGj4cammVzX/bcla8hgW5Iz89A S/xZ1HG+ofWwfv01w88zNruda05q4mE0JfZN9x1HtLynSUhhxCDbhyrl3prOpIlnGa XaJym9P6D98DQrOlYl/+frxu+Q0rR4C7qr7wWm0VtR2xeEvrNIOrd9RL686wyhdrLT Z3UihtpwVMJG1svS4yGnLh6vnY8dcy0MM8PjCGnmpOf40GBkVZ32TkcfqgGnJki4NN L1BTrjVizLz8g== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH net] net: hso: fix use-after-free after failed tty open Reply-To: sashiko-reviews@lists.linux.dev To: =?utf-8?b?WWFubmljayBNw7xsbGVy?= Cc: linux-usb@vger.kernel.org In-Reply-To: <20261201101336.164922-1-mail@ynnk.dev> References: <20261201101336.164922-1-mail@ynnk.dev> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 10:15:16 +0000 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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=C3=BCller 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); > =20 > /* setup */ > - tty->driver_data =3D serial; > + if (tty->driver_data !=3D serial) { > + /* The tty holds a reference until hso_serial_cleanup(). */ > + kref_get(&serial->parent->ref); > + tty->driver_data =3D serial; > + } > tty_port_tty_set(&serial->port, tty); > =20 > /* 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 =3D 1 and drops the probe reference without calling hso_stop_serial_device(): drivers/net/usb/hso.c:hso_free_interface() { ... serial =3D dev2ser(serial_table[i]); tty_port_tty_hangup(&serial->port, false); mutex_lock(&serial->parent->mutex); serial->parent->usb_gone =3D 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 <=3D 0) { serial->port.count =3D 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 --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201101336.1649= 22-1-mail@ynnk.dev?part=3D1