2023-03-08 21:02:04

by kernel test robot

[permalink] [raw]
Subject: ld.lld: error: undefined symbol: memcpy

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 63355b9884b3d1677de6bd1517cd2b8a9bf53978
commit: 36be5cba99f6f9984a9a9f0454f95a38f4184d3e kasan: treat meminstrinsic as builtins in uninstrumented files
date: 6 days ago
config: powerpc-randconfig-r036-20230305 (https://download.01.org/0day-ci/archive/20230309/[email protected]/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project 67409911353323ca5edf2049ef0df54132fa1ca7)
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
# install powerpc cross compiling tool for clang build
# apt-get install binutils-powerpc-linux-gnu
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=36be5cba99f6f9984a9a9f0454f95a38f4184d3e
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 36be5cba99f6f9984a9a9f0454f95a38f4184d3e
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=powerpc olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> ld.lld: error: undefined symbol: memcpy
>>> referenced by xmon.c:1896 (arch/powerpc/xmon/xmon.c:1896)
>>> arch/powerpc/xmon/xmon.o:(prregs) in archive vmlinux.a
>>> referenced by zstd_compress.c:4814 (lib/zstd/compress/zstd_compress.c:4814)
>>> lib/zstd/compress/zstd_compress.o:(ZSTD_createCDict_advanced2) in archive vmlinux.a
>>> referenced by zstd_compress.c:4910 (lib/zstd/compress/zstd_compress.c:4910)
>>> lib/zstd/compress/zstd_compress.o:(ZSTD_initStaticCDict) in archive vmlinux.a
>>> referenced 5 more times
--
>> ld.lld: error: undefined symbol: memset
>>> referenced by slab_common.c:579 (mm/slab_common.c:579)
>>> mm/slab_common.o:(kmem_dump_obj) in archive vmlinux.a
>>> referenced by kasan_test.c:558 (mm/kasan/kasan_test.c:558)
>>> mm/kasan/kasan_test.o:(kmalloc_oob_in_memset) in archive vmlinux.a
>>> referenced by kasan_test.c:505 (mm/kasan/kasan_test.c:505)
>>> mm/kasan/kasan_test.o:(kmalloc_oob_memset_2) in archive vmlinux.a
>>> referenced 10 more times

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests


2023-03-08 21:07:48

by Andrew Morton

[permalink] [raw]
Subject: Re: ld.lld: error: undefined symbol: memcpy

On Thu, 9 Mar 2023 05:01:04 +0800 kernel test robot <[email protected]> wrote:

> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 63355b9884b3d1677de6bd1517cd2b8a9bf53978
> commit: 36be5cba99f6f9984a9a9f0454f95a38f4184d3e kasan: treat meminstrinsic as builtins in uninstrumented files
> date: 6 days ago
> config: powerpc-randconfig-r036-20230305 (https://download.01.org/0day-ci/archive/20230309/[email protected]/config)
> compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project 67409911353323ca5edf2049ef0df54132fa1ca7)
> 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
> # install powerpc cross compiling tool for clang build
> # apt-get install binutils-powerpc-linux-gnu
> # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=36be5cba99f6f9984a9a9f0454f95a38f4184d3e
> git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> git fetch --no-tags linus master
> git checkout 36be5cba99f6f9984a9a9f0454f95a38f4184d3e
> # save the config file
> mkdir build_dir && cp config build_dir/.config
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=powerpc olddefconfig
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash
>
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <[email protected]>
> | Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
>
> All errors (new ones prefixed by >>):
>
> >> ld.lld: error: undefined symbol: memcpy
> >>> referenced by xmon.c:1896 (arch/powerpc/xmon/xmon.c:1896)
> >>> arch/powerpc/xmon/xmon.o:(prregs) in archive vmlinux.a
> >>> referenced by zstd_compress.c:4814 (lib/zstd/compress/zstd_compress.c:4814)
> >>> lib/zstd/compress/zstd_compress.o:(ZSTD_createCDict_advanced2) in archive vmlinux.a
> >>> referenced by zstd_compress.c:4910 (lib/zstd/compress/zstd_compress.c:4910)
> >>> lib/zstd/compress/zstd_compress.o:(ZSTD_initStaticCDict) in archive vmlinux.a
> >>> referenced 5 more times
> --
> >> ld.lld: error: undefined symbol: memset
> >>> referenced by slab_common.c:579 (mm/slab_common.c:579)
> >>> mm/slab_common.o:(kmem_dump_obj) in archive vmlinux.a
> >>> referenced by kasan_test.c:558 (mm/kasan/kasan_test.c:558)
> >>> mm/kasan/kasan_test.o:(kmalloc_oob_in_memset) in archive vmlinux.a
> >>> referenced by kasan_test.c:505 (mm/kasan/kasan_test.c:505)
> >>> mm/kasan/kasan_test.o:(kmalloc_oob_memset_2) in archive vmlinux.a
> >>> referenced 10 more times
>

Will this fix?

From: Alexander Potapenko <[email protected]>
Subject: x86: kmsan: don't rename memintrinsics in uninstrumented files
Date: Fri, 3 Mar 2023 15:14:30 +0100

clang -fsanitize=kernel-memory already replaces calls to
memset/memcpy/memmove and their __builtin_ versions with
__msan_memset/__msan_memcpy/__msan_memmove in instrumented files, so
there is no need to override them.

In non-instrumented versions we are now required to leave memset() and
friends intact, so we cannot replace them with __msan_XXX() functions.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Alexander Potapenko <[email protected]>
Suggested-by: Marco Elver <[email protected]>
Reviewed-by: Marco Elver <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Daniel Vetter <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: Tetsuo Handa <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
---


--- a/arch/x86/include/asm/string_64.h~x86-kmsan-dont-rename-memintrinsics-in-uninstrumented-files
+++ a/arch/x86/include/asm/string_64.h
@@ -15,22 +15,11 @@
#endif

#define __HAVE_ARCH_MEMCPY 1
-#if defined(__SANITIZE_MEMORY__) && defined(__NO_FORTIFY)
-#undef memcpy
-#define memcpy __msan_memcpy
-#else
extern void *memcpy(void *to, const void *from, size_t len);
-#endif
extern void *__memcpy(void *to, const void *from, size_t len);

#define __HAVE_ARCH_MEMSET
-#if defined(__SANITIZE_MEMORY__) && defined(__NO_FORTIFY)
-extern void *__msan_memset(void *s, int c, size_t n);
-#undef memset
-#define memset __msan_memset
-#else
void *memset(void *s, int c, size_t n);
-#endif
void *__memset(void *s, int c, size_t n);

#define __HAVE_ARCH_MEMSET16
@@ -70,13 +59,7 @@ static inline void *memset64(uint64_t *s
}

#define __HAVE_ARCH_MEMMOVE
-#if defined(__SANITIZE_MEMORY__) && defined(__NO_FORTIFY)
-#undef memmove
-void *__msan_memmove(void *dest, const void *src, size_t len);
-#define memmove __msan_memmove
-#else
void *memmove(void *dest, const void *src, size_t count);
-#endif
void *__memmove(void *dest, const void *src, size_t count);

int memcmp(const void *cs, const void *ct, size_t count);
_


2023-03-08 22:15:42

by Marco Elver

[permalink] [raw]
Subject: Re: ld.lld: error: undefined symbol: memcpy

On Wed, 8 Mar 2023 at 22:07, Andrew Morton <[email protected]> wrote:
>
> On Thu, 9 Mar 2023 05:01:04 +0800 kernel test robot <[email protected]> wrote:
>
> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head: 63355b9884b3d1677de6bd1517cd2b8a9bf53978
> > commit: 36be5cba99f6f9984a9a9f0454f95a38f4184d3e kasan: treat meminstrinsic as builtins in uninstrumented files
> > date: 6 days ago
> > config: powerpc-randconfig-r036-20230305 (https://download.01.org/0day-ci/archive/20230309/[email protected]/config)
> > compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project 67409911353323ca5edf2049ef0df54132fa1ca7)
> > 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
> > # install powerpc cross compiling tool for clang build
> > # apt-get install binutils-powerpc-linux-gnu
> > # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=36be5cba99f6f9984a9a9f0454f95a38f4184d3e
> > git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> > git fetch --no-tags linus master
> > git checkout 36be5cba99f6f9984a9a9f0454f95a38f4184d3e
> > # save the config file
> > mkdir build_dir && cp config build_dir/.config
> > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=powerpc olddefconfig
> > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash
> >
> > If you fix the issue, kindly add following tag where applicable
> > | Reported-by: kernel test robot <[email protected]>
> > | Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
> >
> > All errors (new ones prefixed by >>):
> >
> > >> ld.lld: error: undefined symbol: memcpy
> > >>> referenced by xmon.c:1896 (arch/powerpc/xmon/xmon.c:1896)
> > >>> arch/powerpc/xmon/xmon.o:(prregs) in archive vmlinux.a
> > >>> referenced by zstd_compress.c:4814 (lib/zstd/compress/zstd_compress.c:4814)
> > >>> lib/zstd/compress/zstd_compress.o:(ZSTD_createCDict_advanced2) in archive vmlinux.a
> > >>> referenced by zstd_compress.c:4910 (lib/zstd/compress/zstd_compress.c:4910)
> > >>> lib/zstd/compress/zstd_compress.o:(ZSTD_initStaticCDict) in archive vmlinux.a
> > >>> referenced 5 more times
> > --
> > >> ld.lld: error: undefined symbol: memset
> > >>> referenced by slab_common.c:579 (mm/slab_common.c:579)
> > >>> mm/slab_common.o:(kmem_dump_obj) in archive vmlinux.a
> > >>> referenced by kasan_test.c:558 (mm/kasan/kasan_test.c:558)
> > >>> mm/kasan/kasan_test.o:(kmalloc_oob_in_memset) in archive vmlinux.a
> > >>> referenced by kasan_test.c:505 (mm/kasan/kasan_test.c:505)
> > >>> mm/kasan/kasan_test.o:(kmalloc_oob_memset_2) in archive vmlinux.a
> > >>> referenced 10 more times
> >
>
> Will this fix?

I think this patch got lost:
https://lkml.kernel.org/r/[email protected]

By the looks of it 36be5cba99f6f9984a9a9f0454f95a38f4184d3e in
mainline doesn't have any of the powerpc bits.

Thanks,
-- Marco