Skip to content

ublk: fix NULL pointer dereference in ublk_ctrl_set_size()#623

Open
blktests-ci[bot] wants to merge 1 commit intolinus-master_basefrom
series/1062146=>linus-master
Open

ublk: fix NULL pointer dereference in ublk_ctrl_set_size()#623
blktests-ci[bot] wants to merge 1 commit intolinus-master_basefrom
series/1062146=>linus-master

Conversation

@blktests-ci
Copy link

@blktests-ci blktests-ci bot commented Mar 5, 2026

Pull request for series with
subject: ublk: fix NULL pointer dereference in ublk_ctrl_set_size()
version: 1
url: https://patchwork.kernel.org/project/linux-block/list/?series=1062146

@blktests-ci
Copy link
Author

blktests-ci bot commented Mar 5, 2026

Upstream branch: c107785
series: https://patchwork.kernel.org/project/linux-block/list/?series=1062146
version: 1

@blktests-ci
Copy link
Author

blktests-ci bot commented Mar 5, 2026

Upstream branch: 5ee8dbf
series: https://patchwork.kernel.org/project/linux-block/list/?series=1062146
version: 1

@blktests-ci blktests-ci bot force-pushed the series/1062146=>linus-master branch from ef187db to 4221ace Compare March 5, 2026 21:38
@blktests-ci blktests-ci bot force-pushed the linus-master_base branch from 901a429 to 1f19ba6 Compare March 10, 2026 06:29
@blktests-ci
Copy link
Author

blktests-ci bot commented Mar 10, 2026

Upstream branch: 1f318b9
series: https://patchwork.kernel.org/project/linux-block/list/?series=1062146
version: 1

@blktests-ci blktests-ci bot force-pushed the series/1062146=>linus-master branch from 4221ace to 24704e1 Compare March 10, 2026 06:29
@blktests-ci blktests-ci bot force-pushed the linus-master_base branch from 1f19ba6 to e79276a Compare March 11, 2026 08:02
@blktests-ci
Copy link
Author

blktests-ci bot commented Mar 11, 2026

Upstream branch: None
series: https://patchwork.kernel.org/project/linux-block/list/?series=1062146
version: 1

@blktests-ci blktests-ci bot force-pushed the series/1062146=>linus-master branch from 24704e1 to bb2e75b Compare March 11, 2026 08:02
@blktests-ci blktests-ci bot force-pushed the linus-master_base branch from e79276a to 0dd9afc Compare March 12, 2026 01:40
@blktests-ci
Copy link
Author

blktests-ci bot commented Mar 12, 2026

Upstream branch: 80234b5
series: https://patchwork.kernel.org/project/linux-block/list/?series=1062146
version: 1

ublk_ctrl_set_size() unconditionally dereferences ub->ub_disk via
set_capacity_and_notify() without checking if it is NULL.

ub->ub_disk is NULL before UBLK_CMD_START_DEV completes (it is only
assigned in ublk_ctrl_start_dev()) and after UBLK_CMD_STOP_DEV runs
(ublk_detach_disk() sets it to NULL). Since the UBLK_CMD_UPDATE_SIZE
handler performs no state validation, a user can trigger a NULL pointer
dereference by sending UPDATE_SIZE to a device that has been added but
not yet started, or one that has been stopped.

Fix this by checking ub->ub_disk under ub->mutex before dereferencing
it, and returning -ENODEV if the disk is not available.

Fixes: 98b9956 ("ublk: Add UBLK_U_CMD_UPDATE_SIZE")
Cc: stable@vger.kernel.org
Signed-off-by: Mehul Rao <mehulrao@gmail.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
@blktests-ci blktests-ci bot force-pushed the series/1062146=>linus-master branch from bb2e75b to 37a812f Compare March 12, 2026 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant