ublk: don't clear GD_SUPPRESS_PART_SCAN for unprivileged daemons
Subsystems (2)
PATCH 1/1 ublk: don't clear GD_SUPPRESS_PART_SCAN for unprivileged daemons
When UBLK_F_NO_AUTO_PART_SCAN is set, GD_SUPPRESS_PART_SCAN is cleared unconditionally, including for unprivileged daemons. Keep it consistent with the code block for setting GD_SUPPRESS_PART_SCAN by not clearing it for unprivileged daemons.
In reality this isn't a problem because ioctl(BLKRRPART) requires CAP_SYS_ADMIN, but it is more reliable to not clear the bit.
--- drivers/block/ublk_drv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/block/ublk_drv.c +3 -1
@@ -4443,7 +4443,9 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub,/* Skip partition scan if disabled by user */ if (ub->dev_info.flags &UBLK_F_NO_AUTO_PART_SCAN ) { -clear_bit (GD_SUPPRESS_PART_SCAN , &disk->state); +/* Not clear for unprivileged daemons, see comment above */ +if (!ub->unprivileged_daemons) +clear_bit (GD_SUPPRESS_PART_SCAN , &disk->state); }else {/* Schedule async partition scan for trusted daemons */ if (!ub->unprivileged_daemons)
Signature · 1 line
2.47.1
Quoted 9 lines · Ming Lei
When
UBLK_F_NO_AUTO_PART_SCANis set,GD_SUPPRESS_PART_SCANis cleared unconditionally, including for unprivileged daemons. Keep it consistent with the code block for settingGD_SUPPRESS_PART_SCANby not clearing it for unprivileged daemons.In reality this isn't a problem because ioctl(BLKRRPART) requires
CAP_SYS_ADMIN, but it is more reliable to not clear the bit.[...]
Applied, thanks!
[1/1] ublk: don't clear GD_SUPPRESS_PART_SCAN for unprivileged daemons
commit: 155a3bedccaf57c69aa0b590ba3fb579debf3a4d
Best regards,
Signature · 1 line
Jens Axboe
Quoted 21 lines · Ming Lei
When
UBLK_F_NO_AUTO_PART_SCANis set,GD_SUPPRESS_PART_SCANis cleared unconditionally, including for unprivileged daemons. Keep it consistent with the code block for settingGD_SUPPRESS_PART_SCANby not clearing it for unprivileged daemons.In reality this isn't a problem because ioctl(BLKRRPART) requires
CAP_SYS_ADMIN, but it is more reliable to not clear the bit.Cc Alexander Atanasov <[email protected]>Fixes 8443e2087e70 ("ublk: add UBLK_F_NO_AUTO_PART_SCAN feature flag")Signed-off-by Ming Lei <[email protected]>--- drivers/block/ublk_drv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/block/ublk_drv.c +0
-0
drivers/block/ublk_drv.c static int ublk_ctrl_start_dev(struct ublk_device *ub, · line 4451
Quoted 10 lines
drivers/block/ublk_drv.c +3
-1@@ -4443,7 +4443,9 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub,/* Skip partition scan if disabled by user */ if (ub->dev_info.flags &UBLK_F_NO_AUTO_PART_SCAN ) { -clear_bit (GD_SUPPRESS_PART_SCAN , &disk->state); +/* Not clear for unprivileged daemons, see comment above */ +if (!ub->unprivileged_daemons) +clear_bit (GD_SUPPRESS_PART_SCAN , &disk->state); }else {/* Schedule async partition scan for trusted daemons */ if (!ub->unprivileged_daemons)
Looks like the two if (!ub->unprivileged_daemons) checks could be moved outside the if (ub->dev_info.flags & UBLK_F_NO_AUTO_PART_SCAN) to reduce repetition. But the logic looks fine to me.
Best,
Caleb
Quoted 3 lines
--
2.47.1