mm/kasan/shadow.c:49: multiple definition of `memset'; arch/x86/lib/memset_64.o:arch/x86/um/../lib/memset_64.S:29: first defined here

From: kernel test robot
Date: Sat Jun 17 2023 - 01:17:25 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 1639fae5132bc8a904af28d97cea0bedb3af802e
commit: 69d4c0d3218692ffa56b0e1b9c76c50c699d7044 entry, kasan, x86: Disallow overriding mem*() functions
date: 5 months ago
config: um-randconfig-r012-20230617 (https://download.01.org/0day-ci/archive/20230617/202306171302.fa4CDGXG-lkp@xxxxxxxxx/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build):
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=69d4c0d3218692ffa56b0e1b9c76c50c699d7044
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 69d4c0d3218692ffa56b0e1b9c76c50c699d7044
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=um olddefconfig
make W=1 O=build_dir ARCH=um SHELL=/bin/bash

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202306171302.fa4CDGXG-lkp@xxxxxxxxx/

All errors (new ones prefixed by >>):

ld: mm/kasan/shadow.o: in function `memset':
>> mm/kasan/shadow.c:49: multiple definition of `memset'; arch/x86/lib/memset_64.o:arch/x86/um/../lib/memset_64.S:29: first defined here
ld: mm/kasan/shadow.o: in function `memmove':
>> mm/kasan/shadow.c:59: multiple definition of `memmove'; arch/x86/lib/memmove_64.o:arch/x86/um/../lib/memmove_64.S:31: first defined here
ld: mm/kasan/shadow.o: in function `memcpy':
>> mm/kasan/shadow.c:70: multiple definition of `memcpy'; arch/x86/lib/memcpy_64.o:arch/x86/um/../lib/memcpy_64.S:32: first defined here


vim +49 mm/kasan/shadow.c

bb359dbcb70085 Andrey Konovalov 2020-12-22 40
69d4c0d3218692 Peter Zijlstra 2023-01-12 41 #ifndef CONFIG_GENERIC_ENTRY
69d4c0d3218692 Peter Zijlstra 2023-01-12 42 /*
69d4c0d3218692 Peter Zijlstra 2023-01-12 43 * CONFIG_GENERIC_ENTRY relies on compiler emitted mem*() calls to not be
69d4c0d3218692 Peter Zijlstra 2023-01-12 44 * instrumented. KASAN enabled toolchains should emit __asan_mem*() functions
69d4c0d3218692 Peter Zijlstra 2023-01-12 45 * for the sites they want to instrument.
69d4c0d3218692 Peter Zijlstra 2023-01-12 46 */
bb359dbcb70085 Andrey Konovalov 2020-12-22 47 #undef memset
bb359dbcb70085 Andrey Konovalov 2020-12-22 48 void *memset(void *addr, int c, size_t len)
bb359dbcb70085 Andrey Konovalov 2020-12-22 @49 {
f00748bfa0246c Andrey Konovalov 2021-02-24 50 if (!kasan_check_range((unsigned long)addr, len, true, _RET_IP_))
bb359dbcb70085 Andrey Konovalov 2020-12-22 51 return NULL;
bb359dbcb70085 Andrey Konovalov 2020-12-22 52
bb359dbcb70085 Andrey Konovalov 2020-12-22 53 return __memset(addr, c, len);
bb359dbcb70085 Andrey Konovalov 2020-12-22 54 }
bb359dbcb70085 Andrey Konovalov 2020-12-22 55
bb359dbcb70085 Andrey Konovalov 2020-12-22 56 #ifdef __HAVE_ARCH_MEMMOVE
bb359dbcb70085 Andrey Konovalov 2020-12-22 57 #undef memmove
bb359dbcb70085 Andrey Konovalov 2020-12-22 58 void *memmove(void *dest, const void *src, size_t len)
bb359dbcb70085 Andrey Konovalov 2020-12-22 @59 {
f00748bfa0246c Andrey Konovalov 2021-02-24 60 if (!kasan_check_range((unsigned long)src, len, false, _RET_IP_) ||
f00748bfa0246c Andrey Konovalov 2021-02-24 61 !kasan_check_range((unsigned long)dest, len, true, _RET_IP_))
bb359dbcb70085 Andrey Konovalov 2020-12-22 62 return NULL;
bb359dbcb70085 Andrey Konovalov 2020-12-22 63
bb359dbcb70085 Andrey Konovalov 2020-12-22 64 return __memmove(dest, src, len);
bb359dbcb70085 Andrey Konovalov 2020-12-22 65 }
bb359dbcb70085 Andrey Konovalov 2020-12-22 66 #endif
bb359dbcb70085 Andrey Konovalov 2020-12-22 67
bb359dbcb70085 Andrey Konovalov 2020-12-22 68 #undef memcpy
bb359dbcb70085 Andrey Konovalov 2020-12-22 69 void *memcpy(void *dest, const void *src, size_t len)
bb359dbcb70085 Andrey Konovalov 2020-12-22 @70 {
f00748bfa0246c Andrey Konovalov 2021-02-24 71 if (!kasan_check_range((unsigned long)src, len, false, _RET_IP_) ||
f00748bfa0246c Andrey Konovalov 2021-02-24 72 !kasan_check_range((unsigned long)dest, len, true, _RET_IP_))
bb359dbcb70085 Andrey Konovalov 2020-12-22 73 return NULL;
bb359dbcb70085 Andrey Konovalov 2020-12-22 74
bb359dbcb70085 Andrey Konovalov 2020-12-22 75 return __memcpy(dest, src, len);
bb359dbcb70085 Andrey Konovalov 2020-12-22 76 }
69d4c0d3218692 Peter Zijlstra 2023-01-12 77 #endif
69d4c0d3218692 Peter Zijlstra 2023-01-12 78

:::::: The code at line 49 was first introduced by commit
:::::: bb359dbcb70085a63e8bdbf14837a900750f0cf7 kasan: split out shadow.c from common.c

:::::: TO: Andrey Konovalov <andreyknvl@xxxxxxxxxx>
:::::: CC: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>

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