ceph: fix possible integer overflow in ceph_zero_objects()
PATCH 1/1 ceph: fix possible integer overflow in ceph_zero_objects()
In 'ceph_zero_objects', promote 'object_size' to 'u64' to avoid possible integer overflow.
Compile tested only.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- fs/ceph/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/file.c +1 -1
@@ -2616,7 +2616,7 @@ static int ceph_zero_objects(struct inode *inode, loff_t offset, loff_t length)s32 stripe_unit = ci->i_layout.stripe_unit;s32 stripe_count = ci->i_layout.stripe_count;s32 object_size = ci->i_layout.object_size; -u64 object_set_size = object_size * stripe_count; +u64 object_set_size = (u64 ) object_size * stripe_count;u64 nearly, t;/* round offset up to next period boundary */
Signature · 1 line
2.43.5
Quoted 16 lines · Dmitry Kandybka
In '
ceph_zero_objects', promote 'object_size' to 'u64' to avoid possible integer overflow.
Compile tested only.Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by Dmitry Kandybka <[email protected]>--- fs/ceph/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/ceph/file.c +0
-0
fs/ceph/file.c static int ceph_zero_objects(struct inode *inode, loff_t offset, loff_t length) · line 2618
Quoted 3 lines
fs/ceph/file.c +0
-0@@ -2616,7 +2616,7 @@ static int ceph_zero_objects(struct inode *inode, loff_t offset, loff_t length)s32 stripe_unit = ci->i_layout.stripe_unit;s32 stripe_count = ci->i_layout.stripe_count;s32 object_size = ci->i_layout.object_size;
Frankly speaking, I don't quite follow why we are using signed type here (s32). As object size as stripe count should be positive value always.
fs/ceph/file.c static int ceph_zero_objects(struct inode *inode, loff_t offset, loff_t length) · line 2622
Quoted 5 lines
fs/ceph/file.c +1
-1-u64 object_set_size = object_size * stripe_count; +u64 object_set_size = (u64 ) object_size * stripe_count;u64 nearly, t;/* round offset up to next period boundary */
Looks good.
Thanks,
Slava.