[openeuler:OLK-5.10 3304/3304] include/linux/sunrpc/xdr.h:606:10: warning: result of comparison of constant 4611686018427387903 with expression of type '__u32' (aka 'unsigned int') is always false
tree: https://gitee.com/openeuler/kernel.git OLK-5.10 head: 4a93a68b1fa420e5791d9f16414d427f8dd90fb4 commit: fd2b905e3179865f7a512dfcfe14f10b6067236d [3304/3304] NFSD: prevent integer overflow on 32 bit systems config: x86_64-allnoconfig (https://download.01.org/0day-ci/archive/20251124/202511241524.zGjjHi86-lkp@i...) compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 9e9fe08b16ea2c4d9867fb4974edf2a3776d6ece) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251124/202511241524.zGjjHi86-lkp@i...) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202511241524.zGjjHi86-lkp@intel.com/ All warnings (new ones prefixed by >>): In file included from init/do_mounts.c:23: In file included from include/linux/nfs_fs.h:31: In file included from include/linux/sunrpc/auth.h:13: In file included from include/linux/sunrpc/sched.h:19:
include/linux/sunrpc/xdr.h:606:10: warning: result of comparison of constant 4611686018427387903 with expression of type '__u32' (aka 'unsigned int') is always false [-Wtautological-constant-out-of-range-compare] 606 | if (len > SIZE_MAX / sizeof(*p)) | ~~~ ^ ~~~~~~~~~~~~~~~~~~~~~ 1 warning generated.
vim +606 include/linux/sunrpc/xdr.h 584 585 /** 586 * xdr_stream_decode_uint32_array - Decode variable length array of integers 587 * @xdr: pointer to xdr_stream 588 * @array: location to store the integer array or NULL 589 * @array_size: number of elements to store 590 * 591 * Return values: 592 * On success, returns number of elements stored in @array 593 * %-EBADMSG on XDR buffer overflow 594 * %-EMSGSIZE if the size of the array exceeds @array_size 595 */ 596 static inline ssize_t 597 xdr_stream_decode_uint32_array(struct xdr_stream *xdr, 598 __u32 *array, size_t array_size) 599 { 600 __be32 *p; 601 __u32 len; 602 ssize_t retval; 603 604 if (unlikely(xdr_stream_decode_u32(xdr, &len) < 0)) 605 return -EBADMSG;
606 if (len > SIZE_MAX / sizeof(*p)) 607 return -EBADMSG; 608 p = xdr_inline_decode(xdr, len * sizeof(*p)); 609 if (unlikely(!p)) 610 return -EBADMSG; 611 if (array == NULL) 612 return len; 613 if (len <= array_size) { 614 if (len < array_size) 615 memset(array+len, 0, (array_size-len)*sizeof(*array)); 616 array_size = len; 617 retval = len; 618 } else 619 retval = -EMSGSIZE; 620 for (; array_size > 0; p++, array++, array_size--) 621 *array = be32_to_cpup(p); 622 return retval; 623 } 624
-- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
participants (1)
-
kernel test robot