Linux USB
 help / color / mirror / Atom feed
From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: Lucas De Marchi <ldemarchi@nvidia.com>,
	Mathias Nyman <mathias.nyman@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	demarchi@kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 1/3] xhci: dbgtty: Fix unregister on tty_register_driver() failure
Date: Tue, 28 Jul 2026 12:12:53 +0300	[thread overview]
Message-ID: <35af8a6d-6303-4dc8-a2fb-f10a1e4968dd@linux.intel.com> (raw)
In-Reply-To: <20260720202716.76000-1-ldemarchi@nvidia.com>

On 7/20/26 23:27, Lucas De Marchi wrote:
> If tty_register_driver() fails, it drops the reference, but fails to set
> the global dbc_tty_driver to NULL, causing the unregister to be called
> again when module exits.
> 
> On module unload dbc_tty_exit() only gates its cleanup on the driver
> pointer being non-NULL, so it operates on the already-freed driver:
> 
>      module_init(xhci_hcd_init)
>        xhci_hcd_init()
>          xhci_dbc_init()                       [return value ignored]
>            dbc_tty_init()
>              tty_register_driver() fails
>                tty_driver_kref_put()           -> driver freed
>                (dbc_tty_driver left dangling)
>      ...
>      module_exit(xhci_hcd_fini)
>        xhci_hcd_fini()
>          xhci_dbc_exit()
>            dbc_tty_exit()
>              if (dbc_tty_driver)               -> true (dangling)
>                tty_unregister_driver()         -> use-after-free
> 
> Fixes: 4521f1613940 ("xhci: dbctty: split dbc tty driver registration and unregistration functions.")
> Cc: stable@vger.kernel.org # v5.10
> Cc: Mathias Nyman <mathias.nyman@linux.intel.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Lucas De Marchi <ldemarchi@nvidia.com>
> ---

Thanks

Added series to queue

-Mathias

      parent reply	other threads:[~2026-07-28  9:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-20 20:27 [PATCH 1/3] xhci: dbgtty: Fix unregister on tty_register_driver() failure Lucas De Marchi
2026-07-20 20:27 ` [PATCH 2/3] xhci: dbgtty: Fix unregister on tty_alloc_driver() failure Lucas De Marchi
2026-07-20 20:27 ` [PATCH 3/3] xhci: dbgtty: Drop extra call to idr_destroy() Lucas De Marchi
2026-07-28  9:12 ` Mathias Nyman [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=35af8a6d-6303-4dc8-a2fb-f10a1e4968dd@linux.intel.com \
    --to=mathias.nyman@linux.intel.com \
    --cc=demarchi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=ldemarchi@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=stable@vger.kernel.org \
    /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