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

From: kbuild test robot
Date: Thu Dec 12 2019 - 00:34:29 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 687dec9b94599b19e218f89fd034d6449c3ff57c
commit: a2ecb233e3e759730269b31b7d8add823cf196ba mips: Kconfig: Add ARCH_HAS_FORTIFY_SOURCE
date: 9 weeks ago
config: mips-randconfig-a001-20191212 (attached as .config)
compiler: mipsel-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout a2ecb233e3e759730269b31b7d8add823cf196ba
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=mips

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

All errors (new ones prefixed by >>):

In file included from include/linux/bitmap.h:9:0,
from include/linux/cpumask.h:12,
from arch/mips/include/asm/processor.h:15,
from arch/mips/include/asm/io.h:31,
from include/linux/io.h:13,
from arch/mips/pistachio/init.c:10:
In function 'memcpy',
inlined from 'mips_nmi_setup' at arch/mips/pistachio/init.c:91:2:
>> include/linux/string.h:355:4: error: call to '__read_overflow2' declared with attribute error: detected read beyond size of object passed as 2nd parameter
__read_overflow2();
^~~~~~~~~~~~~~~~~~
In function 'memcpy',
inlined from 'mips_ejtag_setup' at arch/mips/pistachio/init.c:104:2:
>> include/linux/string.h:355:4: error: call to '__read_overflow2' declared with attribute error: detected read beyond size of object passed as 2nd parameter
__read_overflow2();
^~~~~~~~~~~~~~~~~~

vim +/__read_overflow2 +355 include/linux/string.h

6974f0c4555e28 Daniel Micay 2017-07-12 346
6974f0c4555e28 Daniel Micay 2017-07-12 347 __FORTIFY_INLINE void *memcpy(void *p, const void *q, __kernel_size_t size)
6974f0c4555e28 Daniel Micay 2017-07-12 348 {
6974f0c4555e28 Daniel Micay 2017-07-12 349 size_t p_size = __builtin_object_size(p, 0);
6974f0c4555e28 Daniel Micay 2017-07-12 350 size_t q_size = __builtin_object_size(q, 0);
6974f0c4555e28 Daniel Micay 2017-07-12 351 if (__builtin_constant_p(size)) {
6974f0c4555e28 Daniel Micay 2017-07-12 352 if (p_size < size)
6974f0c4555e28 Daniel Micay 2017-07-12 353 __write_overflow();
6974f0c4555e28 Daniel Micay 2017-07-12 354 if (q_size < size)
6974f0c4555e28 Daniel Micay 2017-07-12 @355 __read_overflow2();
6974f0c4555e28 Daniel Micay 2017-07-12 356 }
6974f0c4555e28 Daniel Micay 2017-07-12 357 if (p_size < size || q_size < size)
6974f0c4555e28 Daniel Micay 2017-07-12 358 fortify_panic(__func__);
6974f0c4555e28 Daniel Micay 2017-07-12 359 return __builtin_memcpy(p, q, size);
6974f0c4555e28 Daniel Micay 2017-07-12 360 }
6974f0c4555e28 Daniel Micay 2017-07-12 361

:::::: The code at line 355 was first introduced by commit
:::::: 6974f0c4555e285ab217cee58b6e874f776ff409 include/linux/string.h: add the option of fortified string.h functions

:::::: TO: Daniel Micay <danielmicay@xxxxxxxxx>
:::::: CC: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx Intel Corporation

Attachment: .config.gz
Description: application/gzip