* [PATCH] ARM: Change arch/arm/lib/mem*.S to use WEAK instead of .weak
@ 2020-11-05 18:15 Fangrui Song
2020-11-05 21:55 ` Nick Desaulniers
2020-11-10 14:05 ` Linus Walleij
0 siblings, 2 replies; 3+ messages in thread
From: Fangrui Song @ 2020-11-05 18:15 UTC (permalink / raw)
To: Linus Walleij
Cc: Florian Fainelli, Fangrui Song, Arnd Bergmann, Abbott Liu,
Nick Desaulniers, Russell King, Mike Rapoport, clang-built-linux,
Andrey Ryabinin, Ard Biesheuvel, linux-arm-kernel
Commit d6d51a96c7d6 ("ARM: 9014/2: Replace string mem* functions for
KASan") add .weak directives to memcpy/memmove/memset to avoid collision
with KASAN interceptors.
This does not work with LLVM's integrated assembler (the assembly snippet
`.weak memcpy ... .globl memcpy` produces a STB_GLOBAL memcpy while GNU as
produces a STB_WEAK memcpy). LLVM 12 (since https://reviews.llvm.org/D90108)
will error on such an overridden symbol binding.
Use the appropriate WEAK macro instead.
Fixes: d6d51a96c7d6 ("ARM: 9014/2: Replace string mem* functions for KASan")
Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Fangrui Song <maskray@google.com>
Link: https://github.com/ClangBuiltLinux/linux/issues/1190
---
arch/arm/lib/memcpy.S | 3 +--
arch/arm/lib/memmove.S | 3 +--
arch/arm/lib/memset.S | 3 +--
3 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/arch/arm/lib/memcpy.S b/arch/arm/lib/memcpy.S
index ad4625d16e11..e4caf48c089f 100644
--- a/arch/arm/lib/memcpy.S
+++ b/arch/arm/lib/memcpy.S
@@ -58,10 +58,9 @@
/* Prototype: void *memcpy(void *dest, const void *src, size_t n); */
-.weak memcpy
ENTRY(__memcpy)
ENTRY(mmiocpy)
-ENTRY(memcpy)
+WEAK(memcpy)
#include "copy_template.S"
diff --git a/arch/arm/lib/memmove.S b/arch/arm/lib/memmove.S
index fd123ea5a5a4..6fecc12a1f51 100644
--- a/arch/arm/lib/memmove.S
+++ b/arch/arm/lib/memmove.S
@@ -24,9 +24,8 @@
* occurring in the opposite direction.
*/
-.weak memmove
ENTRY(__memmove)
-ENTRY(memmove)
+WEAK(memmove)
UNWIND( .fnstart )
subs ip, r0, r1
diff --git a/arch/arm/lib/memset.S b/arch/arm/lib/memset.S
index 0e7ff0423f50..9817cb258c1a 100644
--- a/arch/arm/lib/memset.S
+++ b/arch/arm/lib/memset.S
@@ -13,10 +13,9 @@
.text
.align 5
-.weak memset
ENTRY(__memset)
ENTRY(mmioset)
-ENTRY(memset)
+WEAK(memset)
UNWIND( .fnstart )
ands r3, r0, #3 @ 1 unaligned?
mov ip, r0 @ preserve r0 as return value
--
2.29.1.341.ge80a0c044ae-goog
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ARM: Change arch/arm/lib/mem*.S to use WEAK instead of .weak
2020-11-05 18:15 [PATCH] ARM: Change arch/arm/lib/mem*.S to use WEAK instead of .weak Fangrui Song
@ 2020-11-05 21:55 ` Nick Desaulniers
2020-11-10 14:05 ` Linus Walleij
1 sibling, 0 replies; 3+ messages in thread
From: Nick Desaulniers @ 2020-11-05 21:55 UTC (permalink / raw)
To: Fangrui Song
Cc: Florian Fainelli, Arnd Bergmann, Abbott Liu, Linus Walleij,
Russell King, Mike Rapoport, clang-built-linux, Andrey Ryabinin,
Ard Biesheuvel, Linux ARM
On Thu, Nov 5, 2020 at 10:15 AM Fangrui Song <maskray@google.com> wrote:
>
> Commit d6d51a96c7d6 ("ARM: 9014/2: Replace string mem* functions for
> KASan") add .weak directives to memcpy/memmove/memset to avoid collision
> with KASAN interceptors.
>
> This does not work with LLVM's integrated assembler (the assembly snippet
> `.weak memcpy ... .globl memcpy` produces a STB_GLOBAL memcpy while GNU as
> produces a STB_WEAK memcpy). LLVM 12 (since https://reviews.llvm.org/D90108)
> will error on such an overridden symbol binding.
>
> Use the appropriate WEAK macro instead.
>
> Fixes: d6d51a96c7d6 ("ARM: 9014/2: Replace string mem* functions for KASan")
> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Fangrui Song <maskray@google.com>
> Link: https://github.com/ClangBuiltLinux/linux/issues/1190
Thank you, this fixes a recent regression for me using LLVM_IAS=1 with ToT LLVM.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
> arch/arm/lib/memcpy.S | 3 +--
> arch/arm/lib/memmove.S | 3 +--
> arch/arm/lib/memset.S | 3 +--
> 3 files changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/arch/arm/lib/memcpy.S b/arch/arm/lib/memcpy.S
> index ad4625d16e11..e4caf48c089f 100644
> --- a/arch/arm/lib/memcpy.S
> +++ b/arch/arm/lib/memcpy.S
> @@ -58,10 +58,9 @@
>
> /* Prototype: void *memcpy(void *dest, const void *src, size_t n); */
>
> -.weak memcpy
> ENTRY(__memcpy)
> ENTRY(mmiocpy)
> -ENTRY(memcpy)
> +WEAK(memcpy)
>
> #include "copy_template.S"
>
> diff --git a/arch/arm/lib/memmove.S b/arch/arm/lib/memmove.S
> index fd123ea5a5a4..6fecc12a1f51 100644
> --- a/arch/arm/lib/memmove.S
> +++ b/arch/arm/lib/memmove.S
> @@ -24,9 +24,8 @@
> * occurring in the opposite direction.
> */
>
> -.weak memmove
> ENTRY(__memmove)
> -ENTRY(memmove)
> +WEAK(memmove)
> UNWIND( .fnstart )
>
> subs ip, r0, r1
> diff --git a/arch/arm/lib/memset.S b/arch/arm/lib/memset.S
> index 0e7ff0423f50..9817cb258c1a 100644
> --- a/arch/arm/lib/memset.S
> +++ b/arch/arm/lib/memset.S
> @@ -13,10 +13,9 @@
> .text
> .align 5
>
> -.weak memset
> ENTRY(__memset)
> ENTRY(mmioset)
> -ENTRY(memset)
> +WEAK(memset)
> UNWIND( .fnstart )
> ands r3, r0, #3 @ 1 unaligned?
> mov ip, r0 @ preserve r0 as return value
> --
> 2.29.1.341.ge80a0c044ae-goog
>
--
Thanks,
~Nick Desaulniers
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ARM: Change arch/arm/lib/mem*.S to use WEAK instead of .weak
2020-11-05 18:15 [PATCH] ARM: Change arch/arm/lib/mem*.S to use WEAK instead of .weak Fangrui Song
2020-11-05 21:55 ` Nick Desaulniers
@ 2020-11-10 14:05 ` Linus Walleij
1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2020-11-10 14:05 UTC (permalink / raw)
To: Fangrui Song
Cc: Florian Fainelli, Arnd Bergmann, Abbott Liu, Nick Desaulniers,
Russell King, Mike Rapoport, clang-built-linux, Andrey Ryabinin,
Ard Biesheuvel, Linux ARM
On Thu, Nov 5, 2020 at 7:15 PM Fangrui Song <maskray@google.com> wrote:
> Commit d6d51a96c7d6 ("ARM: 9014/2: Replace string mem* functions for
> KASan") add .weak directives to memcpy/memmove/memset to avoid collision
> with KASAN interceptors.
>
> This does not work with LLVM's integrated assembler (the assembly snippet
> `.weak memcpy ... .globl memcpy` produces a STB_GLOBAL memcpy while GNU as
> produces a STB_WEAK memcpy). LLVM 12 (since https://reviews.llvm.org/D90108)
> will error on such an overridden symbol binding.
>
> Use the appropriate WEAK macro instead.
>
> Fixes: d6d51a96c7d6 ("ARM: 9014/2: Replace string mem* functions for KASan")
> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Fangrui Song <maskray@google.com>
> Link: https://github.com/ClangBuiltLinux/linux/issues/1190
Acked-by: Linus Walleij <linus.walleij@linaro.org>
When you have consensus that this is working, please put the patch
into Russell's patch tracker.
Yours,
Linus Walleij
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-10 14:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-05 18:15 [PATCH] ARM: Change arch/arm/lib/mem*.S to use WEAK instead of .weak Fangrui Song
2020-11-05 21:55 ` Nick Desaulniers
2020-11-10 14:05 ` Linus Walleij
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.