Whamcloud - gitweb
LU-19059 lov: fix lov_stripe_set 36/59436/3
authorVladimir Saveliev <vladimir.saveliev@hpe.com>
Wed, 4 Jun 2025 16:18:14 +0000 (19:18 +0300)
committerOleg Drokin <green@whamcloud.com>
Sat, 7 Jun 2025 22:53:00 +0000 (22:53 +0000)
Prevent overflow on multiplication of 32 bit integers.

Test to illustrate the issue is added to hit overflow in both branches
of lov_stripe_set().

Fixes: 6eee4ea5b6 ("LU-6174 lov: use standard Linux 64 divison macros")
HPE-bug-id: LUS-12782
Signed-off-by: Vladimir Saveliev <vladimir.saveliev@hpe.com>
Change-Id: If5a5aaf8de98c79b3df908e0d052461a3c8d0989
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/59436
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Alexey Lyashkov <alexey.lyashkov@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/lov/lov_offset.c
lustre/tests/sanity.sh

index 3a0bbbe..a672ee5 100644 (file)
@@ -35,7 +35,7 @@ u64 stripe_width(struct lov_stripe_md *lsm, unsigned int index)
 u64 lov_stripe_size(struct lov_stripe_md *lsm, int index, u64 ost_size,
                    int stripeno)
 {
-       u32 ssize = lsm->lsm_entries[index]->lsme_stripe_size;
+       u64 ssize = lsm->lsm_entries[index]->lsme_stripe_size;
        u32 stripe_size;
        u64 swidth;
        u64 lov_size;
index 434327e..3b59163 100755 (executable)
@@ -6074,6 +6074,25 @@ test_44f() {
 }
 run_test 44f "Check fiemap for sparse files"
 
+test_44g() {
+       # max stripe size is 4G - 64K
+       $LFS setstripe -C 4 -S 4194240k $DIR/$tfile
+       dd if=/dev/zero of=$DIR/$tfile conv=notrunc bs=64k count=1 \
+          seek=$((65535 * 3 + 65533))
+
+       $LFS setstripe -c 2 -S 2g $DIR/$tfile-2
+       dd if=/dev/zero of=$DIR/$tfile-2 conv=notrunc bs=64k count=1 \
+          seek=65535
+
+       cancel_lru_locks osc
+
+       $CHECKSTAT -s $(((65535 * 3 + 65534) * 65536)) $DIR/$tfile ||
+           error "wrong $DIR/$tfile size"
+       $CHECKSTAT -s 4294967296 $DIR/$tfile-2 ||
+           error "wrong $DIR/$tfile-2 size"
+}
+run_test 44g "test overflow in lov_stripe_size"
+
 dirty_osc_total() {
        tot=0
        for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do