Whamcloud - gitweb
LU-17517 lov: fix large shift in lov_update_statfs() 43/54043/4
authorTimothy Day <timday@amazon.com>
Wed, 14 Feb 2024 06:17:00 +0000 (06:17 +0000)
committerOleg Drokin <green@whamcloud.com>
Sat, 23 Mar 2024 05:54:48 +0000 (05:54 +0000)
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 <ake.sandgren@hpc2n.umu.se>
Signed-off-by: Timothy Day <timday@amazon.com>
Change-Id: I9ed6dd145279631e8a362c85c6fd46f147ab6946
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54043
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/lov/lov_request.c

index 83cb50b..77dff64 100644 (file)
@@ -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;