]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ublk: snapshot batch commands before preparing I/O
authorYousef Alhouseen <alhouseenyousef@gmail.com>
Tue, 30 Jun 2026 21:18:27 +0000 (23:18 +0200)
committerJens Axboe <axboe@kernel.dk>
Thu, 2 Jul 2026 12:25:21 +0000 (06:25 -0600)
commitf01f5275feb77bac9fefbbf7cc584fe0b3850a92
treed1d9638c2e78a4c30add35c26c2d9d93c7d9b6d8
parent1e56f30a73f304fe26a272742c398aedd88a1a6c
ublk: snapshot batch commands before preparing I/O

The batch prepare path rereads its userspace element array when rolling
back a partially prepared batch. Userspace can change an already
processed tag before the second read, causing rollback to reject the
replacement tag and leave earlier I/O slots prepared. The
WARN_ON_ONCE() in the rollback path then fires.

Copy the bounded batch into kernel memory before changing any I/O state
and use the same snapshot for preparation and rollback. Commit and fetch
batches retain the existing chunked userspace walk.

Fixes: b256795b3606 ("ublk: handle UBLK_U_IO_PREP_IO_CMDS")
Reported-by: syzbot+1a67ee1aa79484801ec6@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=1a67ee1aa79484801ec6
Signed-off-by: Yousef Alhouseen <alhouseenyousef@gmail.com>
Reviewed-by: Ming Lei <tom.leiming@gmail.com>
Link: https://patch.msgid.link/20260630211827.50475-1-alhouseenyousef@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ublk_drv.c