Skip to content

ublk: fix struct ublksrv_ctrl_cmd accesses

Caleb Sander Mateos linux-block lkml 2 versions – Applied

Status from this message: Applied, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 4 repliesApplied
  2. v14 patches 4 repliesSuperseded

Changes in v2 from the cover letter

- Make a local copy of the struct ublksrv_ctrl_cmd (Ming)
- Add Reviewed-by tag (Ming)

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/3ublk: Validate SQE128 flag before accessing the cmddrivers/block/ublk_drv.c+3 -30 replies
2/3ublk: use READ_ONCE() to read struct ublksrv_ctrl_cmddrivers/block/ublk_drv.c+31 -252 replies
3/3ublk: drop ublk_ctrl_start_recovery() header argumentdrivers/block/ublk_drv.c+3 -41 reply

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchCaleb Sander MateosMing Lei
1/3R-b R-b
2/3R-b
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/3] ublk: fix struct ublksrv_ctrl_cmd accesses

struct ublksrv_ctrl_cmd is part of the io_uring_sqe. Since commit 87213b0d847c ("ublk: allow non-blocking ctrl cmds in IO_URING_F_NONBLOCK issue") allowed some commands to be handled in the non-blocking issue, the SQE may lie in userspace-mapped memory. Validate that the SQE size is the expected 128 bytes before dereferencing it. Use READ_ONCE() to copy the ublksrv_ctrl_cmd from the SQE to a local variable. This avoids data races if userspace writes to the SQE concurrently.

v2:
- Make a local copy of the struct ublksrv_ctrl_cmd (Ming)
- Add Reviewed-by tag (Ming)

Caleb Sander Mateos (2):
ublk: use READ_ONCE() to read struct ublksrv_ctrl_cmd
ublk: drop ublk_ctrl_start_recovery() header argument

Govindarajulu Varadarajan (1):
ublk: Validate SQE128 flag before accessing the cmd

 drivers/block/ublk_drv.c | 65 +++++++++++++++++++++-------------------
 1 file changed, 35 insertions(+), 30 deletions(-)
Signature · 1 line
2.45.2