Re: [PATCH 2/4] ublk: don't write to struct ublksrv_ctrl_cmd
From: Ming Lei
Date: Fri Jan 30 2026 - 11:06:19 EST
On Fri, Jan 30, 2026 at 11:48 PM Ming Lei <ming.lei@xxxxxxxxxx> wrote:
>
> On Thu, Jan 29, 2026 at 03:46:15PM -0700, Caleb Sander Mateos wrote:
> > ublk_ctrl_uring_cmd_permission() writes to struct ublksrv_ctrl_cmd's
> > addr and len fields, which is racy because ublksrv_ctrl_cmd is part of
> > the io_uring_sqe, which may lie in userspace-mapped memory. Store the
> > values of addr in len in local variables instead to avoid the race.
> >
> > Fixes: 87213b0d847c ("ublk: allow non-blocking ctrl cmds in IO_URING_F_NONBLOCK issue")
> > Signed-off-by: Caleb Sander Mateos <csander@xxxxxxxxxxxxxxx>
>
> The simpler approach is to define local `header` variable and copy data to
> it.
Given READ_ONCE() is still needed in patch 3, I'd suggest to fix by adding
local `struct ublksrv_ctrl_cmd` shadow variable in an easy & reliable way.
Thanks,