From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Jiasheng Jiang <jiashengjiangcool@gmail.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
"andrzej.p@samsung.com" <andrzej.p@samsung.com>,
"bigeasy@linutronix.de" <bigeasy@linutronix.de>,
"chenyufeng@iie.ac.cn" <chenyufeng@iie.ac.cn>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"nab@linux-iscsi.org" <nab@linux-iscsi.org>
Subject: Re: [PATCH] usb: gadget: f_tcm: Fix NULL pointer dereferences in nexus handling
Date: Thu, 19 Feb 2026 02:17:58 +0000 [thread overview]
Message-ID: <20260219021757.eeq35yd7jumpk42n@synopsys.com> (raw)
In-Reply-To: <20260219014455.14351-1-jiashengjiangcool@gmail.com>
On Thu, Feb 19, 2026, Jiasheng Jiang wrote:
> The `tpg->tpg_nexus` pointer in the USB Target driver is dynamically
> managed and tied to userspace configuration via ConfigFS. It can be
> NULL if the USB host sends requests before the nexus is fully
> established or immediately after it is dropped.
>
> Currently, functions like `bot_submit_command()` and the data
> transfer paths retrieve `tv_nexus = tpg->tpg_nexus` and immediately
> dereference `tv_nexus->tvn_se_sess` without any validation. If a
> malicious or misconfigured USB host sends a BOT (Bulk-Only Transport)
> command during this race window, it triggers a NULL pointer
> dereference, leading to a kernel panic (local DoS).
>
> This exposes an inconsistent API usage within the module, as peer
> functions like `usbg_submit_command()` and `bot_send_bad_response()`
> correctly implement a NULL check for `tv_nexus` before proceeding.
>
> Fix this by bringing consistency to the nexus handling. Add the
> missing `if (!tv_nexus)` checks to the vulnerable BOT command and
> request processing paths, aborting the command gracefully with an
> error instead of crashing the system.
>
> Fixes: 08a1cb0f65fd ("usb: gadget: tcm: factor out f_tcm")
> Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
> ---
> drivers/usb/gadget/function/f_tcm.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c
> index 6e8804f04baa..9554ddd9b4b8 100644
> --- a/drivers/usb/gadget/function/f_tcm.c
> +++ b/drivers/usb/gadget/function/f_tcm.c
> @@ -1222,6 +1222,11 @@ static void usbg_submit_cmd(struct usbg_cmd *cmd)
> se_cmd = &cmd->se_cmd;
> tpg = cmd->fu->tpg;
> tv_nexus = tpg->tpg_nexus;
> + if (!tv_nexus) {
> + pr_err("Missing nexus, ignoring command\n");
Use dev_err.
BR,
Thinh
next prev parent reply other threads:[~2026-02-19 2:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-16 20:48 Jiasheng Jiang
2026-02-18 5:22 ` Thinh Nguyen
2026-02-18 7:29 ` Sebastian Andrzej Siewior
2026-02-19 1:30 ` Thinh Nguyen
2026-02-19 1:44 ` Jiasheng Jiang
2026-02-19 2:17 ` Thinh Nguyen [this message]
2026-02-19 2:38 ` [PATCH v3] " Jiasheng Jiang
2026-02-19 22:57 ` Thinh Nguyen
2026-02-19 1:48 ` [PATCH] " Jiasheng Jiang
2026-02-19 2:13 ` Thinh Nguyen
2026-02-19 2:18 ` [PATCH v2] " Jiasheng Jiang
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=20260219021757.eeq35yd7jumpk42n@synopsys.com \
--to=thinh.nguyen@synopsys.com \
--cc=andrzej.p@samsung.com \
--cc=bigeasy@linutronix.de \
--cc=chenyufeng@iie.ac.cn \
--cc=gregkh@linuxfoundation.org \
--cc=jiashengjiangcool@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=nab@linux-iscsi.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
all inboxes | Powered by JetHome®