arch/x86/include/asm/string_32.h:182:25: warning: '__builtin_memcpy' specified bound 4294967295 exceeds maximum object size 2147483647

From: kernel test robot
Date: Sun Nov 05 2023 - 06:52:08 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: aea6bf908d730b01bd264a8821159db9463c111c
commit: ae271c1b14de343b888e77f74f640e3dcbdeb4c9 landlock: Add ruleset and domain management
date: 2 years, 6 months ago
config: i386-buildonly-randconfig-r002-20220101 (https://download.01.org/0day-ci/archive/20231105/202311051904.8hqTj5mc-lkp@xxxxxxxxx/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231105/202311051904.8hqTj5mc-lkp@xxxxxxxxx/reproduce)

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@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311051904.8hqTj5mc-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

In file included from arch/x86/include/asm/string.h:3,
from include/linux/string.h:21,
from include/linux/bitmap.h:9,
from include/linux/cpumask.h:12,
from include/linux/smp.h:13,
from include/linux/lockdep.h:14,
from security/landlock/ruleset.c:15:
security/landlock/ruleset.c: In function 'create_rule':
>> arch/x86/include/asm/string_32.h:182:25: warning: '__builtin_memcpy' specified bound 4294967295 exceeds maximum object size 2147483647 [-Wstringop-overflow=]
182 | #define memcpy(t, f, n) __builtin_memcpy(t, f, n)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
security/landlock/ruleset.c:96:9: note: in expansion of macro 'memcpy'
96 | memcpy(new_rule->layers, layers,
| ^~~~~~


vim +/__builtin_memcpy +182 arch/x86/include/asm/string_32.h

^1da177e4c3f41 include/asm-i386/string.h Linus Torvalds 2005-04-16 177
^1da177e4c3f41 include/asm-i386/string.h Linus Torvalds 2005-04-16 178 /*
^1da177e4c3f41 include/asm-i386/string.h Linus Torvalds 2005-04-16 179 * No 3D Now!
^1da177e4c3f41 include/asm-i386/string.h Linus Torvalds 2005-04-16 180 */
^1da177e4c3f41 include/asm-i386/string.h Linus Torvalds 2005-04-16 181
ff60fab71bb3b4 arch/x86/include/asm/string_32.h Arjan van de Ven 2009-09-28 @182 #define memcpy(t, f, n) __builtin_memcpy(t, f, n)
^1da177e4c3f41 include/asm-i386/string.h Linus Torvalds 2005-04-16 183

:::::: The code at line 182 was first introduced by commit
:::::: ff60fab71bb3b4fdbf8caf57ff3739ffd0887396 x86: Use __builtin_memset and __builtin_memcpy for memset/memcpy

:::::: TO: Arjan van de Ven <arjan@xxxxxxxxxxxxx>
:::::: CC: H. Peter Anvin <hpa@xxxxxxxxx>

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