From: Vladimir Saveliev Date: Wed, 4 Jun 2025 16:18:14 +0000 (+0300) Subject: LU-19059 lov: fix lov_stripe_set X-Git-Tag: 2.16.56~35 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=0e2410381a915bebf76bad6c72adeb02803dfe49;p=fs%2Flustre-release.git LU-19059 lov: fix lov_stripe_set 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 Change-Id: If5a5aaf8de98c79b3df908e0d052461a3c8d0989 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/59436 Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Reviewed-by: Alexey Lyashkov Reviewed-by: Oleg Drokin --- diff --git a/lustre/lov/lov_offset.c b/lustre/lov/lov_offset.c index 3a0bbbe..a672ee5 100644 --- a/lustre/lov/lov_offset.c +++ b/lustre/lov/lov_offset.c @@ -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; diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 434327e..3b59163 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -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