[kees:kspp/memcpy/next-20210803/v2-devel 77/86] include/linux/string.h:297:2: error: implicit declaration of function '__underlying_memcpy'; did you mean '__builtin_memcpy'?
From: kernel test robot
Date: Wed Aug 11 2021 - 19:16:55 EST
tree: https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git kspp/memcpy/next-20210803/v2-devel
head: 4752984fc24104f399e70f99d48afa047d86a381
commit: 0faff4e74f49485683ea9757f2e49fdab41c7f20 [77/86] netlink: Use flex_cpy() to avoid false-positive memcpy() warning
config: nios2-defconfig (attached as .config)
compiler: nios2-linux-gcc (GCC) 10.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/kees/linux.git/commit/?id=0faff4e74f49485683ea9757f2e49fdab41c7f20
git remote add kees https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git
git fetch --no-tags kees kspp/memcpy/next-20210803/v2-devel
git checkout 0faff4e74f49485683ea9757f2e49fdab41c7f20
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross ARCH=nios2
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
All errors (new ones prefixed by >>):
In file included from include/linux/bitmap.h:10,
from include/linux/cpumask.h:12,
from include/linux/mm_types_task.h:14,
from include/linux/mm_types.h:5,
from include/linux/buildid.h:5,
from include/linux/module.h:14,
from net/netlink/af_netlink.c:21:
net/netlink/af_netlink.c: In function 'netlink_ack':
>> include/linux/string.h:297:2: error: implicit declaration of function '__underlying_memcpy'; did you mean '__builtin_memcpy'? [-Werror=implicit-function-declaration]
297 | __underlying_memcpy(dst, src, __src_bytes); \
| ^~~~~~~~~~~~~~~~~~~
net/netlink/af_netlink.c:2452:2: note: in expansion of macro 'flex_cpy'
2452 | flex_cpy(&errmsg->msg, errlen, nlh, errlen, nlmsg_content);
| ^~~~~~~~
cc1: some warnings being treated as errors
vim +297 include/linux/string.h
01f33c336e2d29 Martin Wilck 2017-08-14 274
1e9264c10e1d25 Kees Cook 2021-08-10 275 /** flex_cpy - Copy between two flexible array members.
1e9264c10e1d25 Kees Cook 2021-08-10 276 *
1e9264c10e1d25 Kees Cook 2021-08-10 277 * @dst: Destination pointer
1e9264c10e1d25 Kees Cook 2021-08-10 278 * @dst_count: Number of @member elements to copy at end of @dst struct
1e9264c10e1d25 Kees Cook 2021-08-10 279 * @src: Source pointer
1e9264c10e1d25 Kees Cook 2021-08-10 280 * @src_count: Number of @member elements to copy from end of @src struct
1e9264c10e1d25 Kees Cook 2021-08-10 281 * @member: The flexible array member of both @src and @dst
1e9264c10e1d25 Kees Cook 2021-08-10 282 *
1e9264c10e1d25 Kees Cook 2021-08-10 283 * The full structure of @src will be copied to @dst, as well as
1e9264c10e1d25 Kees Cook 2021-08-10 284 * @src_count @member elements. @src and @dst must reference the same type.
1e9264c10e1d25 Kees Cook 2021-08-10 285 * @dst_count must be >= @src_count.
1e9264c10e1d25 Kees Cook 2021-08-10 286 */
1e9264c10e1d25 Kees Cook 2021-08-10 287 #define flex_cpy(dst, dst_count, src, src_count, member) ({ \
1e9264c10e1d25 Kees Cook 2021-08-10 288 size_t __dst_bytes = struct_size(dst, member, dst_count); \
1e9264c10e1d25 Kees Cook 2021-08-10 289 size_t __src_bytes = struct_size(src, member, src_count); \
1e9264c10e1d25 Kees Cook 2021-08-10 290 BUILD_BUG_ON(!__same_type(*(dst), *(src))); \
1e9264c10e1d25 Kees Cook 2021-08-10 291 WARN_ONCE(IS_ENABLED(CONFIG_FORTIFY_SOURCE) && \
1e9264c10e1d25 Kees Cook 2021-08-10 292 __dst_bytes < __src_bytes, \
1e9264c10e1d25 Kees Cook 2021-08-10 293 "flex_cpy: detected write overflow (size %zu) of %s (size %zu)\n", \
1e9264c10e1d25 Kees Cook 2021-08-10 294 __src_bytes, \
1e9264c10e1d25 Kees Cook 2021-08-10 295 "field \"" #dst "\" at " __FILE__ ":" __stringify(__LINE__), \
1e9264c10e1d25 Kees Cook 2021-08-10 296 __dst_bytes); \
1e9264c10e1d25 Kees Cook 2021-08-10 @297 __underlying_memcpy(dst, src, __src_bytes); \
1e9264c10e1d25 Kees Cook 2021-08-10 298 })
1e9264c10e1d25 Kees Cook 2021-08-10 299
:::::: The code at line 297 was first introduced by commit
:::::: 1e9264c10e1d259549421c6f5adfedb80144a6b3 string: Introduce flexible array memcpy() helpers
:::::: TO: Kees Cook <keescook@xxxxxxxxxxxx>
:::::: CC: Kees Cook <keescook@xxxxxxxxxxxx>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx
Attachment:
.config.gz
Description: application/gzip