Skip to content

Commit 2e1b3f4

Browse files
nehebaxboe
authored andcommitted
rbd: check snap_count against RBD_MAX_SNAP_COUNT
snap_count is u32 but the comparison is against a SIZE_MAX-derived value (~2^61 on 64-bit), which clang flags as always false with -Wtautological-constant-out-of-range-compare. The proper check here should be that snap_count does not go over RBD_MAX_SNAP_COUNT. Assisted-by: Opencode:Big-pickle Signed-off-by: Rosen Penev <rosenp@gmail.com> Reviewed-by: Alex Elder <elder@riscstar.com> Link: https://patch.msgid.link/20260530011255.52916-1-rosenp@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 2957771 commit 2e1b3f4

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

drivers/block/rbd.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6094,12 +6094,9 @@ static int rbd_dev_v2_snap_context(struct rbd_device *rbd_dev,
60946094

60956095
/*
60966096
* Make sure the reported number of snapshot ids wouldn't go
6097-
* beyond the end of our buffer. But before checking that,
6098-
* make sure the computed size of the snapshot context we
6099-
* allocate is representable in a size_t.
6097+
* beyond the end of our buffer.
61006098
*/
6101-
if (snap_count > (SIZE_MAX - sizeof (struct ceph_snap_context))
6102-
/ sizeof (u64)) {
6099+
if (snap_count > RBD_MAX_SNAP_COUNT) {
61036100
ret = -EINVAL;
61046101
goto out;
61056102
}

0 commit comments

Comments
 (0)