From edbaee798b5e83b0c829cae40419a26f1b0d56c8 Mon Sep 17 00:00:00 2001 From: Timothy Day Date: Wed, 14 Feb 2024 06:17:00 +0000 Subject: [PATCH] LU-17517 lov: fix large shift in lov_update_statfs() UBSAN detected: shift exponent 65 is too large for 64-bit type 'long long unsigned int' in lov_update_statfs() in lov_request.c. This patch caps shift at 32 since os_bsize is of type u32. This avoids the invocation of undefined behavior. Reported-by: Ake Sandgren Signed-off-by: Timothy Day Change-Id: I9ed6dd145279631e8a362c85c6fd46f147ab6946 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54043 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Arshad Hussain Reviewed-by: Oleg Drokin --- lustre/lov/lov_request.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lustre/lov/lov_request.c b/lustre/lov/lov_request.c index 83cb50b..77dff64 100644 --- a/lustre/lov/lov_request.c +++ b/lustre/lov/lov_request.c @@ -197,7 +197,7 @@ lov_update_statfs(struct obd_statfs *osfs, struct obd_statfs *lov_sfs, /* assume all block sizes are always powers of 2 */ /* get the bits difference */ tmp = osfs->os_bsize | lov_sfs->os_bsize; - for (shift = 0; shift <= 64; ++shift) { + for (shift = 0; shift < 32; shift++) { if (tmp & 1) { if (quit) break; -- 1.8.3.1