include/linux/fortify-string.h:187:4: error: call to '__read_overflow2' declared with attribute error: detected read beyond size of object passed as 2nd parameter

From: kernel test robot
Date: Thu Mar 11 2021 - 03:10:16 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: a74e6a014c9d4d4161061f770c9b4f98372ac778
commit: a28a6e860c6cf231cf3c5171c75c342adcd00406 string.h: move fortified functions definitions in a dedicated header.
date: 13 days ago
config: mips-randconfig-r021-20210311 (attached as .config)
compiler: mipsel-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a28a6e860c6cf231cf3c5171c75c342adcd00406
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout a28a6e860c6cf231cf3c5171c75c342adcd00406
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=mips

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

All errors (new ones prefixed by >>):

arch/mips/dec/prom/memory.c: In function 'pmax_setup_memory_region':
arch/mips/dec/prom/memory.c:32:39: warning: variable 'dummy' set but not used [-Wunused-but-set-variable]
32 | volatile unsigned char *memory_page, dummy;
| ^~~~~
In file included from include/linux/string.h:269,
from include/linux/bitmap.h:9,
from include/linux/cpumask.h:12,
from arch/mips/include/asm/processor.h:15,
from arch/mips/include/asm/thread_info.h:16,
from include/linux/thread_info.h:58,
from include/asm-generic/preempt.h:5,
from ./arch/mips/include/generated/asm/preempt.h:1,
from include/linux/preempt.h:78,
from include/linux/spinlock.h:51,
from include/linux/mmzone.h:8,
from include/linux/gfp.h:6,
from include/linux/mm.h:10,
from arch/mips/dec/prom/memory.c:10:
In function 'memcpy',
inlined from 'prom_meminit' at arch/mips/dec/prom/memory.c:38:2:
>> include/linux/fortify-string.h:187:4: error: call to '__read_overflow2' declared with attribute error: detected read beyond size of object passed as 2nd parameter
187 | __read_overflow2();
| ^~~~~~~~~~~~~~~~~~


vim +/__read_overflow2 +187 include/linux/fortify-string.h

177
178 __FORTIFY_INLINE void *memcpy(void *p, const void *q, __kernel_size_t size)
179 {
180 size_t p_size = __builtin_object_size(p, 0);
181 size_t q_size = __builtin_object_size(q, 0);
182
183 if (__builtin_constant_p(size)) {
184 if (p_size < size)
185 __write_overflow();
186 if (q_size < size)
> 187 __read_overflow2();
188 }
189 if (p_size < size || q_size < size)
190 fortify_panic(__func__);
191 return __underlying_memcpy(p, q, size);
192 }
193

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip