From: Greg KH <gregkh@linuxfoundation.org>
To: Yehyeong Lee <yhlee@isslab.korea.ac.kr>
Cc: nkapron@google.com, linux-usb@vger.kernel.org,
Thinh.Nguyen@synopsys.com, bigeasy@linutronix.de,
target-devel@vger.kernel.org, linux-kernel@vger.kernel.org,
lgs201920130244@gmail.com
Subject: Re: [PATCH] usb: gadget: f_tcm: do not dequeue UAS stream requests in BOT mode
Date: Fri, 20 Nov 2026 14:42:56 +0100 [thread overview]
Message-ID: <2026112031-sandlot-idealness-df6f@gregkh> (raw)
In-Reply-To: <20261120113956.3071640-1-yhlee@isslab.korea.ac.kr>
On Fri, Nov 20, 2026 at 08:39:56PM +0900, Yehyeong Lee wrote:
> usbg_aborted_task() starts by reading stream->req_out->status. The
> stream requests are allocated by uasp_alloc_stream_res() for the UAS
> alternate setting only, so in BOT mode they are NULL.
>
> The target core calls .aborted_task() from target_handle_abort() for an
> aborted command whose CMD_T_TAS is clear. A BOT command gets there when
> a LUN RESET arrives on another fabric that exports the same backstore
> and the backstore has emulate_tas set to 0: core_tmr_drain_state_list()
> aborts every command on the device, no TASK ABORTED status is owed, and
> the core calls .aborted_task(), where the read faults. With the default
> emulate_tas of 1 the core sends TASK ABORTED status instead.
>
> Return early unless the function is in UAS mode. A BOT transfer uses
> fu->bot_req_in and fu->bot_req_out, not the stream requests.
>
> Reproduced on dummy_hcd in BOT mode with a fileio backstore that is also
> exported through tcm_loop and has emulate_tas set to 0: a WRITE(10) has
> its data stage held while SG_SCSI_RESET_DEVICE on the loopback disk
> issues the LUN RESET. Without this patch 3 of 3 boots oops as below;
> with it none do, and the write does not reach the backing store.
>
> BUG: kernel NULL pointer dereference, address: 000000000000005c
> #PF: supervisor read access in kernel mode
> #PF: error_code(0x0000) - not-present page
> PGD 0 P4D 0
> Oops: Oops: 0000 [#1] SMP NOPTI
> CPU: 1 UID: 0 PID: 30 Comm: kworker/1:1 Not tainted 7.4.0-rc3-FT9NNM-00395-g8dac6df92a2e #1 PREEMPT(lazy)
> Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
> Workqueue: target_completion target_abort_work
> RIP: 0010:usbg_aborted_task+0x2d/0xc0
> Code: fa 55 53 48 8b 87 e0 01 00 00 48 89 fb 48 8b 50 38 48 8b 52 30 48 8b 2a 8b 57 24 48 8d 14 d2 48 8d 14 d0 48 8b b2 58 03 00 00 <83> 7e 5c 8d 74 2b 48 8b b2 50 03 00 00 83 7e 5c 8d 74 58 48 8b b2
> RSP: 0018:ffffc90000107e40 EFLAGS: 00010246
> RAX: ffff88800540d000 RBX: ffff888006c6c870 RCX: 0000000000000001
> RDX: ffff88800540d6c0 RSI: 0000000000000000 RDI: ffff888006c6c870
> RBP: ffff8880053febc8 R08: 8080808080808080 R09: ffff88800491c218
> R10: ffff888005031cc0 R11: fefefefefefefeff R12: ffff88807db295c0
> R13: ffff888006c6c9a8 R14: ffff888005031805 R15: 0000000000000000
> FS: 0000000000000000(0000) GS:ffff8880f9e92000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 000000000000005c CR3: 0000000003030002 CR4: 0000000000770ef0
> PKRU: 55555554
> Call Trace:
> <TASK>
> target_handle_abort+0x6b/0x130
> process_one_work+0x19e/0x3f0
> worker_thread+0x180/0x2f0
> ? __pfx_worker_thread+0x10/0x10
> kthread+0xee/0x120
> ? __pfx_kthread+0x10/0x10
> ret_from_fork+0x186/0x230
> ? __pfx_kthread+0x10/0x10
> ret_from_fork_asm+0x1a/0x30
> </TASK>
> Modules linked in:
> CR2: 000000000000005c
> ---[ end trace 0000000000000000 ]---
> note: kworker/1:1[30] exited with irqs disabled
>
> Fixes: 76003eb6d09278 ("usb: gadget: f_tcm: Handle abort command")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yehyeong Lee <yhlee@isslab.korea.ac.kr>
> ---
> drivers/usb/gadget/function/f_tcm.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c
> index 9e6d4f39900a27..57e2ec81f29a8a 100644
> --- a/drivers/usb/gadget/function/f_tcm.c
> +++ b/drivers/usb/gadget/function/f_tcm.c
> @@ -1614,6 +1614,10 @@ static void usbg_aborted_task(struct se_cmd *se_cmd)
> struct uas_stream *stream = &fu->stream[se_cmd->map_tag];
> int ret = 0;
>
> + /* the stream requests exist only in UAS mode */
> + if (!(fu->flags & USBG_IS_UAS))
> + return;
What prevents the flags from changing right after you read them?
thanks,
greg k-h
next prev parent reply other threads:[~2026-11-20 13:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 11:39 [PATCH] usb: gadget: f_tcm: do not dequeue UAS stream requests in BOT mode Yehyeong Lee
2026-11-20 11:47 ` sashiko-bot
2026-11-20 13:42 ` Greg KH [this message]
2026-11-20 16:08 ` Yehyeong Lee
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=2026112031-sandlot-idealness-df6f@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=Thinh.Nguyen@synopsys.com \
--cc=bigeasy@linutronix.de \
--cc=lgs201920130244@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=nkapron@google.com \
--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.