[gustavoars-linux:for-next/Warray-bounds 3/3] include/uapi/linux/bcache.h:109:32: warning: 'memcpy' offset [17, 24] from the object at 'alloc' is out of the bounds of referenced subobject 'key' with type 'struct bkey' at offset 0

From: kernel test robot
Date: Mon Jun 07 2021 - 23:02:18 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git for-next/Warray-bounds
head: 12f0a8412db185d4fe79208083b373a0c02b6ee9
commit: 12f0a8412db185d4fe79208083b373a0c02b6ee9 [3/3] Makefile: Enable -Warray-bounds
config: nds32-allyesconfig (attached as .config)
compiler: nds32le-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/gustavoars/linux.git/commit/?id=12f0a8412db185d4fe79208083b373a0c02b6ee9
git remote add gustavoars-linux https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git
git fetch --no-tags gustavoars-linux for-next/Warray-bounds
git checkout 12f0a8412db185d4fe79208083b373a0c02b6ee9
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=nds32

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

All warnings (new ones prefixed by >>):

In file included from drivers/md/bcache/bcache.h:181,
from drivers/md/bcache/alloc.c:64:
In function 'pick_data_bucket',
inlined from 'bch_alloc_sectors' at drivers/md/bcache/alloc.c:627:15:
>> include/uapi/linux/bcache.h:109:32: warning: 'memcpy' offset [17, 24] from the object at 'alloc' is out of the bounds of referenced subobject 'key' with type 'struct bkey' at offset 0 [-Warray-bounds]
109 | #define bkey_copy(_dest, _src) memcpy(_dest, _src, bkey_bytes(_src))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/md/bcache/alloc.c:586:3: note: in expansion of macro 'bkey_copy'
586 | bkey_copy(&ret->key, alloc);
| ^~~~~~~~~
--
drivers/media/platform/omap3isp/ispstat.c: In function 'omap3isp_stat_request_statistics_time32':
>> drivers/media/platform/omap3isp/ispstat.c:524:2: warning: 'memcpy' offset [21, 32] from the object at 'data64' is out of the bounds of referenced subobject 'buf' with type 'void *' at offset 16 [-Warray-bounds]
524 | memcpy(&data->buf, &data64.buf, sizeof(*data) - sizeof(data->ts));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +109 include/uapi/linux/bcache.h

81ab4190ac17df Kent Overstreet 2013-10-31 108
81ab4190ac17df Kent Overstreet 2013-10-31 @109 #define bkey_copy(_dest, _src) memcpy(_dest, _src, bkey_bytes(_src))
81ab4190ac17df Kent Overstreet 2013-10-31 110

:::::: The code at line 109 was first introduced by commit
:::::: 81ab4190ac17df41686a37c97f701623276b652a bcache: Pull on disk data structures out into a separate header

:::::: TO: Kent Overstreet <kmo@xxxxxxxxxxxxx>
:::::: CC: Kent Overstreet <kmo@xxxxxxxxxxxxx>

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

Attachment: .config.gz
Description: application/gzip