[gustavoars:testing/fsfa3-next-20230425 1/1] include/linux/fortify-string.h:57:33: warning: '__builtin_memcpy' specified bound between 2147483648 and 4294967295 exceeds maximum object size 2147483647

From: kernel test robot
Date: Tue Apr 25 2023 - 17:24:07 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git testing/fsfa3-next-20230425
head: b82a35ff486df1d6737f532e08e060c466f9e652
commit: b82a35ff486df1d6737f532e08e060c466f9e652 [1/1] Makefile: Enable -Wstringop-overflow and -Warray-bounds
config: i386-randconfig-a014-20230424 (https://download.01.org/0day-ci/archive/20230426/202304260540.8xVWxKhO-lkp@xxxxxxxxx/config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
# https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git/commit/?id=b82a35ff486df1d6737f532e08e060c466f9e652
git remote add gustavoars https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git
git fetch --no-tags gustavoars testing/fsfa3-next-20230425
git checkout b82a35ff486df1d6737f532e08e060c466f9e652
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=i386 olddefconfig
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash fs/udf/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Link: https://lore.kernel.org/oe-kbuild-all/202304260540.8xVWxKhO-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

In file included from include/linux/string.h:254,
from arch/x86/include/asm/page_32.h:18,
from arch/x86/include/asm/page.h:14,
from arch/x86/include/asm/thread_info.h:12,
from include/linux/thread_info.h:60,
from arch/x86/include/asm/preempt.h:9,
from include/linux/preempt.h:78,
from include/linux/spinlock.h:56,
from include/linux/wait.h:9,
from include/linux/wait_bit.h:8,
from include/linux/fs.h:6,
from fs/udf/udfdecl.h:10,
from fs/udf/directory.c:14:
fs/udf/directory.c: In function 'udf_copy_fi':
>> include/linux/fortify-string.h:57:33: warning: '__builtin_memcpy' specified bound between 2147483648 and 4294967295 exceeds maximum object size 2147483647 [-Wstringop-overflow=]
57 | #define __underlying_memcpy __builtin_memcpy
| ^
include/linux/fortify-string.h:585:9: note: in expansion of macro '__underlying_memcpy'
585 | __underlying_##op(p, q, __fortify_size); \
| ^~~~~~~~~~~~~
include/linux/fortify-string.h:630:26: note: in expansion of macro '__fortify_memcpy_chk'
630 | #define memcpy(p, q, s) __fortify_memcpy_chk(p, q, s, \
| ^~~~~~~~~~~~~~~~~~~~
fs/udf/directory.c:103:9: note: in expansion of macro 'memcpy'
103 | memcpy(&iter->fi, iter->bh[0]->b_data + off, len);
| ^~~~~~


vim +/__builtin_memcpy +57 include/linux/fortify-string.h

78a498c3a227f2a Alexander Potapenko 2022-10-24 46
78a498c3a227f2a Alexander Potapenko 2022-10-24 47 #if defined(__SANITIZE_MEMORY__)
78a498c3a227f2a Alexander Potapenko 2022-10-24 48 /*
78a498c3a227f2a Alexander Potapenko 2022-10-24 49 * For KMSAN builds all memcpy/memset/memmove calls should be replaced by the
78a498c3a227f2a Alexander Potapenko 2022-10-24 50 * corresponding __msan_XXX functions.
78a498c3a227f2a Alexander Potapenko 2022-10-24 51 */
78a498c3a227f2a Alexander Potapenko 2022-10-24 52 #include <linux/kmsan_string.h>
78a498c3a227f2a Alexander Potapenko 2022-10-24 53 #define __underlying_memcpy __msan_memcpy
78a498c3a227f2a Alexander Potapenko 2022-10-24 54 #define __underlying_memmove __msan_memmove
78a498c3a227f2a Alexander Potapenko 2022-10-24 55 #define __underlying_memset __msan_memset
78a498c3a227f2a Alexander Potapenko 2022-10-24 56 #else
a28a6e860c6cf23 Francis Laniel 2021-02-25 @57 #define __underlying_memcpy __builtin_memcpy
a28a6e860c6cf23 Francis Laniel 2021-02-25 58 #define __underlying_memmove __builtin_memmove
a28a6e860c6cf23 Francis Laniel 2021-02-25 59 #define __underlying_memset __builtin_memset
78a498c3a227f2a Alexander Potapenko 2022-10-24 60 #endif
78a498c3a227f2a Alexander Potapenko 2022-10-24 61

:::::: The code at line 57 was first introduced by commit
:::::: a28a6e860c6cf231cf3c5171c75c342adcd00406 string.h: move fortified functions definitions in a dedicated header.

:::::: TO: Francis Laniel <laniel_francis@xxxxxxxxxxxxxxxxxxx>
:::::: CC: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests