From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: Greg KH <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, Sang-Hoon Choi <csh0052@gmail.com>,
Changyul Lee <lcy8047@gmail.com>,
Mathias Nyman <mathias.nyman@intel.com>
Subject: Re: [PATCH 06/14] xhci: dbc: lock the minor IDR on registration failure
Date: Fri, 9 Oct 2026 14:16:44 +0300 [thread overview]
Message-ID: <85fc10ab-d718-4a94-bf46-fb60ac2dfbbe@linux.intel.com> (raw)
In-Reply-To: <2026100958-simple-evasion-4048@gregkh>
On 10/9/26 13:52, Greg KH wrote:
> Resending with the proper people in cc...
>
> On Fri, Oct 09, 2026 at 12:51:41PM +0200, Greg KH wrote:
>> On Fri, Oct 09, 2026 at 10:13:10AM +0000, sashiko-bot@kernel.org wrote:
>>> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
>>> - [High] usb: xhci: dbc: UAF due to premature IDR exposure and missing TTY hangup on error path
>>> --
>>>
>>> commit 99c18a1b8449e8389ccac896ceadcc979dbd6a57
>>> Author: Sang-Hoon Choi <csh0052@gmail.com>
>>>
>>> xhci: dbc: lock the minor IDR on registration failure
>>>
>>> This commit fixes a race condition during DbC TTY registration failure
>>> by adding mutex protection around the removal of the minor IDR entry.
>>>
>>>> diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c
>>>> index 3d51e8d82659d..2249cc16800cc 100644
>>>> --- a/drivers/usb/host/xhci-dbgtty.c
>>>> +++ b/drivers/usb/host/xhci-dbgtty.c
>>>> @@ -535,7 +535,9 @@ static int xhci_dbc_tty_register_device(struct xhci_dbc *dbc)
>>>> err_free_fifo:
>>>> kfifo_free(&port->port.xmit_fifo);
>>>> err_exit_port:
>>>> + mutex_lock(&dbc_tty_minors_lock);
>>>> idr_remove(&dbc_tty_minors, port->minor);
>>>> + mutex_unlock(&dbc_tty_minors_lock);
>>>> err_idr:
>>>> xhci_dbc_tty_exit_port(port);
>>>
>>> [Severity: High]
>>> Does this error path leave concurrent TTY sessions pointing to freed memory?
>>>
>>> Earlier in xhci_dbc_tty_register_device(), the port is added to the globally
>>> visible dbc_tty_minors IDR before internal structures are fully allocated:
>>>
>>> mutex_lock(&dbc_tty_minors_lock);
>>> port->minor = idr_alloc(&dbc_tty_minors, port, 0, 64, GFP_KERNEL);
>>> mutex_unlock(&dbc_tty_minors_lock);
>>>
>>> A concurrent open() on the device node routes to dbc_tty_install(), which
>>> retrieves the port and installs the TTY without verifying port->registered:
>>
>> I don't think we need to worry about "concurrent open()" for this as
>> that's not a real use case that I know of and this _should_ be root only
>> accessable, right?
>>
>> Or can normal users open this device node?
>>
No risk of concurrent open as the tty device node is not yet created in this error
path.
This error path is taken if tty_port_register_device() fails, of some other failure
before it
-Mathias
next prev parent reply other threads:[~2026-10-09 11:16 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 9:58 [PATCH 00/14] xhci features and fixes for usb-next Mathias Nyman
2026-10-09 9:58 ` [PATCH 01/14] early: usb: xhci-dbc: Handle out of bounds xhci-xdbc capability Mathias Nyman
2026-10-09 10:11 ` sashiko-bot
2026-10-09 14:52 ` Mathias Nyman
2026-10-09 9:58 ` [PATCH 02/14] usb: xhci: return an error if the host is not halted Mathias Nyman
2026-10-09 10:13 ` sashiko-bot
2026-10-09 9:58 ` [PATCH 03/14] usb: xhci: Unlock for command abort polling Mathias Nyman
2026-10-09 10:10 ` sashiko-bot
2026-10-09 9:58 ` [PATCH 04/14] usb: xhci: fix typos in comments Mathias Nyman
2026-10-09 10:02 ` sashiko-bot
2026-10-09 9:58 ` [PATCH 05/14] xhci: check device notification type before forwarding wake event Mathias Nyman
2026-10-09 10:10 ` sashiko-bot
2026-10-09 9:58 ` [PATCH 06/14] xhci: dbc: lock the minor IDR on registration failure Mathias Nyman
2026-10-09 10:13 ` sashiko-bot
2026-10-09 10:51 ` Greg KH
2026-10-09 10:52 ` Greg KH
2026-10-09 11:16 ` Mathias Nyman [this message]
2026-10-09 11:23 ` Greg KH
2026-10-09 9:58 ` [PATCH 07/14] usb: xhci: sideband: fix ring sg table for sub-page TRB segments Mathias Nyman
2026-10-09 10:15 ` sashiko-bot
2026-10-09 13:35 ` Mathias Nyman
2026-10-09 9:58 ` [PATCH 08/14] usb: xhci-pci: Add TUSB73x0 definitions Mathias Nyman
2026-10-09 10:07 ` sashiko-bot
2026-10-09 12:15 ` Mathias Nyman
2026-10-09 9:58 ` [PATCH 09/14] usb: xhci: Guarantee URB giveback on Ring Underrun/Overrun Mathias Nyman
2026-10-09 10:11 ` sashiko-bot
2026-10-09 9:58 ` [PATCH 10/14] usb: xhci: Don't set the skip flag on non-isoc endpoints Mathias Nyman
2026-10-09 10:16 ` sashiko-bot
2026-10-09 12:06 ` Mathias Nyman
2026-10-09 9:58 ` [PATCH 11/14] usb: xhci: Shorten the TD skipping loop Mathias Nyman
2026-10-09 10:06 ` sashiko-bot
2026-10-09 9:58 ` [PATCH 12/14] usb: xhci: Rework and improve the TD matching and skipping logic Mathias Nyman
2026-10-09 10:15 ` sashiko-bot
2026-10-09 9:58 ` [PATCH 13/14] usb: xhci: Fix bounce buffer overflow Mathias Nyman
2026-10-09 10:15 ` sashiko-bot
2026-10-09 9:58 ` [PATCH 14/14] xhci: Prevent invalid vdev dereference during sideband unregister Mathias Nyman
2026-10-09 10:12 ` sashiko-bot
2026-10-09 10:50 ` [PATCH 00/14] xhci features and fixes for usb-next Greg KH
2026-10-09 11:00 ` Mathias Nyman
2026-10-09 12:23 ` Michal Pecio
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=85fc10ab-d718-4a94-bf46-fb60ac2dfbbe@linux.intel.com \
--to=mathias.nyman@linux.intel.com \
--cc=csh0052@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=lcy8047@gmail.com \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox