[ammarfaizi2-block:crng/random/jd/getrandom-batch 9/9] arch/x86/include/asm/string_32.h:195:29: warning: '__builtin_memset' pointer overflow between offset [0, 255] and size [2147483648, 4294967295]

From: kernel test robot
Date: Tue Aug 02 2022 - 14:48:39 EST


tree: https://github.com/ammarfaizi2/linux-block crng/random/jd/getrandom-batch
head: 99a314f603c9cd173e6db2e3776eb76477283e1a
commit: 99a314f603c9cd173e6db2e3776eb76477283e1a [9/9] random: batch getrandom() output per-task
config: i386-defconfig (https://download.01.org/0day-ci/archive/20220803/202208030247.gT8Fic5N-lkp@xxxxxxxxx/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/ammarfaizi2/linux-block/commit/99a314f603c9cd173e6db2e3776eb76477283e1a
git remote add ammarfaizi2-block https://github.com/ammarfaizi2/linux-block
git fetch --no-tags ammarfaizi2-block crng/random/jd/getrandom-batch
git checkout 99a314f603c9cd173e6db2e3776eb76477283e1a
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

In file included from arch/x86/include/asm/string.h:3,
from include/linux/string.h:20,
from arch/x86/include/asm/page_32.h:22,
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:7,
from include/linux/preempt.h:78,
from include/linux/rcupdate.h:27,
from include/linux/rculist.h:11,
from include/linux/pid.h:5,
from include/linux/sched.h:14,
from include/linux/utsname.h:6,
from drivers/char/random.c:28:
drivers/char/random.c: In function 'get_random_bytes_user.part.0':
>> arch/x86/include/asm/string_32.h:195:29: warning: '__builtin_memset' pointer overflow between offset [0, 255] and size [2147483648, 4294967295] [-Warray-bounds]
195 | #define memset(s, c, count) __builtin_memset(s, c, count)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/char/random.c:425:17: note: in expansion of macro 'memset'
425 | memset(current->rng_batch.buf + current->rng_batch.position, 0, batch_len);
| ^~~~~~


vim +/__builtin_memset +195 arch/x86/include/asm/string_32.h

^1da177e4c3f41 include/asm-i386/string.h Linus Torvalds 2005-04-16 186
^1da177e4c3f41 include/asm-i386/string.h Linus Torvalds 2005-04-16 187 #define __memset(s, c, count) \
78d64fc21d2aa4 include/asm-x86/string_32.h Joe Perches 2008-05-12 188 (__builtin_constant_p(count) \
78d64fc21d2aa4 include/asm-x86/string_32.h Joe Perches 2008-05-12 189 ? __constant_count_memset((s), (c), (count)) \
78d64fc21d2aa4 include/asm-x86/string_32.h Joe Perches 2008-05-12 190 : __memset_generic((s), (c), (count)))
^1da177e4c3f41 include/asm-i386/string.h Linus Torvalds 2005-04-16 191
^1da177e4c3f41 include/asm-i386/string.h Linus Torvalds 2005-04-16 192 #define __HAVE_ARCH_MEMSET
6974f0c4555e28 arch/x86/include/asm/string_32.h Daniel Micay 2017-07-12 193 extern void *memset(void *, int, size_t);
6974f0c4555e28 arch/x86/include/asm/string_32.h Daniel Micay 2017-07-12 194 #ifndef CONFIG_FORTIFY_SOURCE
ff60fab71bb3b4 arch/x86/include/asm/string_32.h Arjan van de Ven 2009-09-28 @195 #define memset(s, c, count) __builtin_memset(s, c, count)
6974f0c4555e28 arch/x86/include/asm/string_32.h Daniel Micay 2017-07-12 196 #endif /* !CONFIG_FORTIFY_SOURCE */
^1da177e4c3f41 include/asm-i386/string.h Linus Torvalds 2005-04-16 197

:::::: The code at line 195 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://01.org/lkp