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 26 2019 - 03:56:44 EST


Hi Dmitry,

FYI, the error/warning still remains.

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 46cf053efec6a3a5f343fead837777efe8252a46
commit: a2ecb233e3e759730269b31b7d8add823cf196ba mips: Kconfig: Add ARCH_HAS_FORTIFY_SOURCE
date: 3 months ago
config: mips-randconfig-a001-20191226 (attached as .config)
compiler: mips64el-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/thread_info.h:16,
from include/linux/thread_info.h:38,
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 include/linux/memblock.h:13,
from arch/mips/loongson64/common/init.c:7:
In function 'memcpy',
inlined from 'mips_nmi_setup' at arch/mips/loongson64/common/init.c:24: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