From: sashiko-bot@kernel.org
To: "Yehyeong Lee" <yhlee@isslab.korea.ac.kr>, linux-usb@vger.kernel.org
Cc: target-devel@vger.kernel.org
Subject: Re: [PATCH] usb: gadget: f_tcm: lock the UAS stream requests in .aborted_task()
Date: Fri, 20 Nov 2026 16:18:27 +0000 [thread overview]
Message-ID: <sashiko-outbox-225553@kernel.org> (raw)
In-Reply-To: <20261120160616.3219043-1-yhlee@isslab.korea.ac.kr>
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] usb: gadget: f_tcm: use-after-free due to stale tpg pointer
in tcm_alloc() [1]
--
commit 6cf4e81d4473dd79e435edcd1431deef1606dc92
Author: Yehyeong Lee <yhlee@isslab.korea.ac.kr>
usb: gadget: f_tcm: lock the UAS stream requests in .aborted_task()
This commit adds fu->stream_lock to synchronize allocation, teardown, and
dequeueing of the UAS stream requests across uasp_alloc_stream_res(),
uasp_cleanup_one_stream(), and usbg_aborted_task().
> diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c
> index 9e6d4f39900a2..21e5ef629319a 100644
> --- a/drivers/usb/gadget/function/f_tcm.c
> +++ b/drivers/usb/gadget/function/f_tcm.c
[ ... ]
> @@ -2757,6 +2777,7 @@ static struct usb_function *tcm_alloc(struct usb_function_instance *fi)
> fu->tpg = tpg_instances[i].tpg;
> INIT_WORK(&fu->delayed_set_alt, tcm_delayed_set_alt);
> spin_lock_init(&fu->delayed_set_alt_lock);
> + spin_lock_init(&fu->stream_lock);
[Severity: Critical]
This problem wasn't introduced by this patch, but caching fu->tpg in
tcm_alloc() [1] can leave a dangling pointer if the TPG is dropped and
recreated before the gadget binds. When userspace removes the TPG,
usbg_drop_tpg() frees it, and creating a new TPG re-enables opts->can_attach
without updating fu->tpg in the already-allocated function. Can tcm_bind()
refresh fu->tpg instead of relying on the pointer cached at allocation time?
[1] https://sashiko.dev/#/bug/linux-abce2989-69f9-4b30-b16f-d2b7ee05baa9
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120160616.3219043-1-yhlee@isslab.korea.ac.kr?part=1
prev parent reply other threads:[~2026-11-20 16:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 16:06 [PATCH] usb: gadget: f_tcm: lock the UAS stream requests in .aborted_task() Yehyeong Lee
2026-11-20 16:18 ` sashiko-bot [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=sashiko-outbox-225553@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=target-devel@vger.kernel.org \
--cc=yhlee@isslab.korea.ac.kr \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.