Linux USB
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Guangshuo Li <lgs201920130244@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiasheng Jiang <jiashengjiangcool@gmail.com>,
	Kees Cook <kees@kernel.org>,
	Mike Christie <michael.christie@oracle.com>,
	Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] usb: gadget: f_tcm: fix remaining nexus NULL dereferences
Date: Sat, 11 Jul 2026 00:50:39 +0000	[thread overview]
Message-ID: <alGSe4pvHykYT6mG@vbox> (raw)
In-Reply-To: <20260704125459.4008712-1-lgs201920130244@gmail.com>

On Sat, Jul 04, 2026, Guangshuo Li wrote:
> The previous nexus NULL-dereference fix added checks to the normal
> command submission paths, but two UASP paths still dereference
> tpg->tpg_nexus without checking it first.
> 
> A TASK MANAGEMENT request reaches usbg_submit_tmr(), which fetches
> tvn_se_sess directly from tpg->tpg_nexus. The RC_OVERLAPPED_TAG path in
> usbg_cmd_work() does the same before walking sess_cmd_map for the active
> command with the same tag.
> 
> If userspace drops the nexus after the command is queued, these paths can
> observe a NULL tpg_nexus and crash before they can ignore the command like
> the already-fixed command paths do.
> 
> Commands that reach the workqueue have already been allocated from the
> session tag pool by usbg_get_cmd(), and UASP commands may have been
> inserted into the stream hash. Clean up those resources before returning
> from nexus-missing paths.
> 
> Store the session pointer in struct usbg_cmd so the cleanup path does not
> need to dereference tpg_nexus after it becomes NULL.
> 
> Fixes: b9fde5073553 ("usb: gadget: f_tcm: Fix NULL pointer dereferences in nexus handling")
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
> ---
> v2:
>   - Clean up the session tag pool and stream hash before returning from
>     nexus-missing paths, as suggested by Thinh.
>   - Store the session pointer in struct usbg_cmd so the cleanup path does
>     not need to dereference tpg_nexus after it becomes NULL.
> 
>  drivers/usb/gadget/function/f_tcm.c | 48 ++++++++++++++++++++++++++---
>  drivers/usb/gadget/function/tcm.h   |  1 +
>  2 files changed, 45 insertions(+), 4 deletions(-)
> 

Reviewed-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>

Thanks,
Thinh

      reply	other threads:[~2026-07-11  0:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-04 12:54 [PATCH v2] usb: gadget: f_tcm: fix remaining nexus NULL dereferences Guangshuo Li
2026-07-11  0:50 ` Thinh Nguyen [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=alGSe4pvHykYT6mG@vbox \
    --to=thinh.nguyen@synopsys.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=gregkh@linuxfoundation.org \
    --cc=jiashengjiangcool@gmail.com \
    --cc=kees@kernel.org \
    --cc=lgs201920130244@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=michael.christie@oracle.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