arch/arm/boot/compressed/decompress.c:50: warning: "memmove" redefined
kernel test robot
build bottree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: b741596468b010af2846b75f5e75a842ce344a6e commit: 421015713b306e47af95d4d61cdfbd96d462e4cb ARM: 9017/2: Enable KASan for ARM date: 6 months ago config: arm-randconfig-r015-20210509 (attached as .config) compiler: arm-linux-gnueabi-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/torvalds/linux.git/commit/?id=421015713b306e47af95d4d61cdfbd96d462e4cb
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 421015713b306e47af95d4d61cdfbd96d462e4cb
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=arm
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
>> arch/arm/boot/compressed/decompress.c:50: warning: "memmove" redefined
50 | #define memmove memmove
|
In file included from arch/arm/boot/compressed/decompress.c:8:
arch/arm/include/asm/string.h:59: note: this is the location of the previous definition
59 | #define memmove(dst, src, len) __memmove(dst, src, len)
|
arch/arm/boot/compressed/decompress.c:51: warning: "memcpy" redefined
51 | #define memcpy memcpy
|
In file included from arch/arm/boot/compressed/decompress.c:8:
arch/arm/include/asm/string.h:58: note: this is the location of the previous definition
58 | #define memcpy(dst, src, len) __memcpy(dst, src, len)
|
arch/arm/boot/compressed/decompress.c:59:5: warning: no previous prototype for 'do_decompress' [-Wmissing-prototypes]
59 | int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x))
| ^~~~~~~~~~~~~
vim +/memmove +50 arch/arm/boot/compressed/decompress.c
6e8699f7d68589 Albin Tonnerre 2010-04-03 48
a7f464f3db93ae Imre Kaloz 2012-01-26 49 #ifdef CONFIG_KERNEL_XZ a7f464f3db93ae Imre Kaloz 2012-01-26 @50 #define memmove memmove a7f464f3db93ae Imre Kaloz 2012-01-26 51 #define memcpy memcpy a7f464f3db93ae Imre Kaloz 2012-01-26 52 #include "../../../../lib/decompress_unxz.c" a7f464f3db93ae Imre Kaloz 2012-01-26 53 #endif a7f464f3db93ae Imre Kaloz 2012-01-26 54
:::::: The code at line 50 was first introduced by commit
:::::: a7f464f3db93ae5492bee6f6e48939fd8a45fa99 ARM: 7001/2: Wire up support for the XZ decompressor
:::::: TO: Imre Kaloz <[email protected]> :::::: CC: Russell King <[email protected]>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Maybe the KASan folk can look into this, it isn't obvious how to fix this, since XZ needs memcpy/memmove #defined to avoid using its own version. Having KASan override these with a #define is all very well, but it makes the behaviour of lib/decompress_unxz.c indeterminant if we get rid of the definitions the XZ support added.
Quoted 59 lines · kernel test robot
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: b741596468b010af2846b75f5e75a842ce344a6e commit: 421015713b306e47af95d4d61cdfbd96d462e4cb ARM: 9017/2: Enable KASan for ARM date: 6 months ago config: arm-randconfig-r015-20210509 (attached as .config) compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0reproduce (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/torvalds/linux.git/commit/?id=421015713b306e47af95d4d61cdfbd96d462e4cb
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout421015713b306e47af95d4d61cdfbd96d462e4cb
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=armIf you fix the issue, kindly add following tag as appropriate
Reported-by kernel test robot <[email protected]>All warnings (new ones prefixed by >>):
Quoted 1 line
Quoted 1 line
arch/arm/boot/compressed/decompress.c:50: warning: "memmove" redefined50 | #define memmove memmove
|
In file included fromarch/arm/boot/compressed/decompress.c:8:
arch/arm/include/asm/string.h:59: note: this is the location of the previous definition
59 | #definememmove(dst, src, len)__memmove(dst, src, len)
|
arch/arm/boot/compressed/decompress.c:51: warning: "memcpy" redefined
51 | #define memcpy memcpy
|
In file included fromarch/arm/boot/compressed/decompress.c:8:
arch/arm/include/asm/string.h:58: note: this is the location of the previous definition
58 | #definememcpy(dst, src, len)__memcpy(dst, src, len)
|
arch/arm/boot/compressed/decompress.c:59:5: warning: no previous prototype for 'do_decompress' [-Wmissing-prototypes]
59 | intdo_decompress(u8 *input, int len, u8 *output, void (*error)(char *x))
| ^~~~~~~~~~~~~vim +/memmove +50
arch/arm/boot/compressed/decompress.c
6e8699f7d68589Albin Tonnerre 2010-04-03 48a7f464f3db93ae Imre Kaloz 2012-01-26 49 #ifdef CONFIG_KERNEL_XZ a7f464f3db93ae Imre Kaloz 2012-01-26 @50 #define memmove memmove a7f464f3db93ae Imre Kaloz 2012-01-26 51 #define memcpy memcpy a7f464f3db93ae Imre Kaloz 2012-01-26 52 #include "../../../../lib/decompress_unxz.c" a7f464f3db93ae Imre Kaloz 2012-01-26 53 #endif a7f464f3db93ae Imre Kaloz 2012-01-26 54:::::: The code at line 50 was first introduced by commit
::::::a7f464f3db93ae5492bee6f6e48939fd8a45fa99ARM: 7001/2: Wire up support for the XZ decompressor:::::: TO: Imre Kaloz <[email protected]> :::::: CC: Russell King <[email protected]>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
OK, paging in the KSan mailing list and key people.
Certainly this problem must be the same on all platforms using an XZ-compressed kernel and not just Arm?
What I wonder is why the other platforms that use XZ compression don't redefine memmove and memcpy in their decompress.c clause for XZ?
Can we just delete these two lines?
#define memmove memmove
#define memcpy memcpy
Imre?
I can test some platforms without these defines later tonight and see what happens.
Yours,
Linus Walleij
Quoted 73 lines · Russell King - ARM Linux admin
Maybe the KASan folk can look into this, it isn't obvious how to fix this, since XZ needs memcpy/memmove #defined to avoid using its own version. Having KASan override these with a #define is all very well, but it makes the behaviour of
lib/decompress_unxz.cindeterminant if we get rid of the definitions the XZ support added.Quoted 53 lines · kernel test robot
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: b741596468b010af2846b75f5e75a842ce344a6e commit: 421015713b306e47af95d4d61cdfbd96d462e4cb ARM: 9017/2: Enable KASan for ARM date: 6 months ago config: arm-randconfig-r015-20210509 (attached as .config) compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0reproduce (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/torvalds/linux.git/commit/?id=421015713b306e47af95d4d61cdfbd96d462e4cb
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout421015713b306e47af95d4d61cdfbd96d462e4cb
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=armIf you fix the issue, kindly add following tag as appropriate
Reported-by kernel test robot <[email protected]>All warnings (new ones prefixed by >>):
Quoted 1 line
Quoted 1 line
arch/arm/boot/compressed/decompress.c:50: warning: "memmove" redefined50 | #define memmove memmove
|
In file included fromarch/arm/boot/compressed/decompress.c:8:
arch/arm/include/asm/string.h:59: note: this is the location of the previous definition
59 | #definememmove(dst, src, len)__memmove(dst, src, len)
|
arch/arm/boot/compressed/decompress.c:51: warning: "memcpy" redefined
51 | #define memcpy memcpy
|
In file included fromarch/arm/boot/compressed/decompress.c:8:
arch/arm/include/asm/string.h:58: note: this is the location of the previous definition
58 | #definememcpy(dst, src, len)__memcpy(dst, src, len)
|
arch/arm/boot/compressed/decompress.c:59:5: warning: no previous prototype for 'do_decompress' [-Wmissing-prototypes]
59 | intdo_decompress(u8 *input, int len, u8 *output, void (*error)(char *x))
| ^~~~~~~~~~~~~vim +/memmove +50
arch/arm/boot/compressed/decompress.c
6e8699f7d68589Albin Tonnerre 2010-04-03 48a7f464f3db93ae Imre Kaloz 2012-01-26 49 #ifdef CONFIG_KERNEL_XZ a7f464f3db93ae Imre Kaloz 2012-01-26 @50 #define memmove memmove a7f464f3db93ae Imre Kaloz 2012-01-26 51 #define memcpy memcpy a7f464f3db93ae Imre Kaloz 2012-01-26 52 #include "../../../../lib/decompress_unxz.c" a7f464f3db93ae Imre Kaloz 2012-01-26 53 #endif a7f464f3db93ae Imre Kaloz 2012-01-26 54:::::: The code at line 50 was first introduced by commit
::::::a7f464f3db93ae5492bee6f6e48939fd8a45fa99ARM: 7001/2: Wire up support for the XZ decompressorQuoted 6 lines
:::::: TO: Imre Kaloz <[email protected]> :::::: CC: Russell King <[email protected]>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Quoted 5 lines · Linus Walleij
OK, paging in the KSan mailing list and key people.
Certainly this problem must be the same on all platforms using an XZ-compressed kernel and not just Arm?
Quoted 7 lines
What I wonder is why the other platforms that use XZ compression don't redefine memmove and memcpy in their
decompress.cclause for XZ?Can we just delete these two lines?
#define memmove memmove
#define memcpy memcpy
We can't. XZ has:
#ifndef memmove
/* Not static to avoid a conflict with the prototype in the Linux
* headers. */
void *memmove(void *dest, const void *src, size_t size) {
...
}
#endif
So, if memmove is not defined in the preprocessor, the code will create its own implementation. memmove() is also defined in arch/arm/boot/compressed/string.c for use with other decompressors, so the local version in lib/decompress_unxz.c will conflict and cause a link time error.
The addition of KASan added this to arch/arm/include/asm/string.h:
#if defined(CONFIG_KASAN) && !defined(__SANITIZE_ADDRESS__) #define memcpy(dst, src, len) __memcpy(dst, src, len) #define memmove(dst, src, len) __memmove(dst, src, len) #define memset(s, c, n) __memset(s, c, n)
#ifndef __NO_FORTIFY
#define __NO_FORTIFY /* FORTIFY_SOURCE uses __builtin_memcpy, etc. */ #endif
#endif
created a conditional definition of memmove in the preprocessor, which ultimately caused this problem. lib/decompress_unxz.c wants it defined in the preprocessor _if_ one has a local implementation (we do.)
Given that KASan should be disabled in the decompressor, maybe the conditional added by KASan to asm/string.h is insufficient? The makefile has:
KASAN_SANITIZE := n
So really we should not be playing _any_ KASan games in the decompressor code.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!