* [PATCH] x86: Fix build of UML with KASAN
@ 2023-06-09 11:18 Vincent Whitchurch
2023-06-10 8:34 ` David Gow
2023-09-11 8:56 ` Peter Zijlstra
0 siblings, 2 replies; 5+ messages in thread
From: Vincent Whitchurch @ 2023-06-09 11:18 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Frederic Weisbecker, Rafael J. Wysocki,
Peter Zijlstra
Cc: Richard Weinberger, Anton Ivanov, Johannes Berg, linux-um,
Andrey Ryabinin, Alexander Potapenko, Andrey Konovalov,
Dmitry Vyukov, Vincenzo Frascino, kasan-dev, linux-kernel, kernel,
Vincent Whitchurch
Building UML with KASAN fails since commit 69d4c0d32186 ("entry, kasan,
x86: Disallow overriding mem*() functions") with the following errors:
$ tools/testing/kunit/kunit.py run --kconfig_add CONFIG_KASAN=y
...
ld: mm/kasan/shadow.o: in function `memset':
shadow.c:(.text+0x40): multiple definition of `memset';
arch/x86/lib/memset_64.o:(.noinstr.text+0x0): first defined here
ld: mm/kasan/shadow.o: in function `memmove':
shadow.c:(.text+0x90): multiple definition of `memmove';
arch/x86/lib/memmove_64.o:(.noinstr.text+0x0): first defined here
ld: mm/kasan/shadow.o: in function `memcpy':
shadow.c:(.text+0x110): multiple definition of `memcpy';
arch/x86/lib/memcpy_64.o:(.noinstr.text+0x0): first defined here
If I'm reading that commit right, the !GENERIC_ENTRY case is still
supposed to be allowed to override the mem*() functions, so use weak
aliases in that case.
Fixes: 69d4c0d32186 ("entry, kasan, x86: Disallow overriding mem*() functions")
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---
arch/x86/lib/memcpy_64.S | 4 ++++
arch/x86/lib/memmove_64.S | 4 ++++
arch/x86/lib/memset_64.S | 4 ++++
3 files changed, 12 insertions(+)
diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
index 8f95fb267caa7..5dc265b36ef0b 100644
--- a/arch/x86/lib/memcpy_64.S
+++ b/arch/x86/lib/memcpy_64.S
@@ -40,7 +40,11 @@ SYM_TYPED_FUNC_START(__memcpy)
SYM_FUNC_END(__memcpy)
EXPORT_SYMBOL(__memcpy)
+#ifdef CONFIG_GENERIC_ENTRY
SYM_FUNC_ALIAS(memcpy, __memcpy)
+#else
+SYM_FUNC_ALIAS_WEAK(memcpy, __memcpy)
+#endif
EXPORT_SYMBOL(memcpy)
SYM_FUNC_START_LOCAL(memcpy_orig)
diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
index 02661861e5dd9..3b1a02357fb29 100644
--- a/arch/x86/lib/memmove_64.S
+++ b/arch/x86/lib/memmove_64.S
@@ -215,5 +215,9 @@ SYM_FUNC_START(__memmove)
SYM_FUNC_END(__memmove)
EXPORT_SYMBOL(__memmove)
+#ifdef CONFIG_GENERIC_ENTRY
SYM_FUNC_ALIAS(memmove, __memmove)
+#else
+SYM_FUNC_ALIAS_WEAK(memmove, __memmove)
+#endif
EXPORT_SYMBOL(memmove)
diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
index 7c59a704c4584..fe27538a355db 100644
--- a/arch/x86/lib/memset_64.S
+++ b/arch/x86/lib/memset_64.S
@@ -40,7 +40,11 @@ SYM_FUNC_START(__memset)
SYM_FUNC_END(__memset)
EXPORT_SYMBOL(__memset)
+#ifdef CONFIG_GENERIC_ENTRY
SYM_FUNC_ALIAS(memset, __memset)
+#else
+SYM_FUNC_ALIAS_WEAK(memset, __memset)
+#endif
EXPORT_SYMBOL(memset)
SYM_FUNC_START_LOCAL(memset_orig)
---
base-commit: 9561de3a55bed6bdd44a12820ba81ec416e705a7
change-id: 20230609-uml-kasan-2392dd4c3858
Best regards,
--
Vincent Whitchurch <vincent.whitchurch@axis.com>
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] x86: Fix build of UML with KASAN
2023-06-09 11:18 [PATCH] x86: Fix build of UML with KASAN Vincent Whitchurch
@ 2023-06-10 8:34 ` David Gow
2023-09-11 7:26 ` Vincent Whitchurch
2023-09-11 8:56 ` Peter Zijlstra
1 sibling, 1 reply; 5+ messages in thread
From: David Gow @ 2023-06-10 8:34 UTC (permalink / raw)
To: Vincent Whitchurch
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Frederic Weisbecker, Rafael J. Wysocki,
Peter Zijlstra, Richard Weinberger, Anton Ivanov, Johannes Berg,
linux-um, Andrey Ryabinin, Alexander Potapenko, Andrey Konovalov,
Dmitry Vyukov, Vincenzo Frascino, kasan-dev, linux-kernel, kernel
[-- Attachment #1: Type: text/plain, Size: 3420 bytes --]
On Fri, 9 Jun 2023 at 19:19, Vincent Whitchurch
<vincent.whitchurch@axis.com> wrote:
>
> Building UML with KASAN fails since commit 69d4c0d32186 ("entry, kasan,
> x86: Disallow overriding mem*() functions") with the following errors:
>
> $ tools/testing/kunit/kunit.py run --kconfig_add CONFIG_KASAN=y
> ...
> ld: mm/kasan/shadow.o: in function `memset':
> shadow.c:(.text+0x40): multiple definition of `memset';
> arch/x86/lib/memset_64.o:(.noinstr.text+0x0): first defined here
> ld: mm/kasan/shadow.o: in function `memmove':
> shadow.c:(.text+0x90): multiple definition of `memmove';
> arch/x86/lib/memmove_64.o:(.noinstr.text+0x0): first defined here
> ld: mm/kasan/shadow.o: in function `memcpy':
> shadow.c:(.text+0x110): multiple definition of `memcpy';
> arch/x86/lib/memcpy_64.o:(.noinstr.text+0x0): first defined here
>
> If I'm reading that commit right, the !GENERIC_ENTRY case is still
> supposed to be allowed to override the mem*() functions, so use weak
> aliases in that case.
>
> Fixes: 69d4c0d32186 ("entry, kasan, x86: Disallow overriding mem*() functions")
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> ---
Thanks: I stumbled into this the other day and ran out of time to debug it.
I've tested that it works here.
Tested-by: David Gow <davidgow@google.com>
Cheers,
-- David
> arch/x86/lib/memcpy_64.S | 4 ++++
> arch/x86/lib/memmove_64.S | 4 ++++
> arch/x86/lib/memset_64.S | 4 ++++
> 3 files changed, 12 insertions(+)
>
> diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
> index 8f95fb267caa7..5dc265b36ef0b 100644
> --- a/arch/x86/lib/memcpy_64.S
> +++ b/arch/x86/lib/memcpy_64.S
> @@ -40,7 +40,11 @@ SYM_TYPED_FUNC_START(__memcpy)
> SYM_FUNC_END(__memcpy)
> EXPORT_SYMBOL(__memcpy)
>
> +#ifdef CONFIG_GENERIC_ENTRY
> SYM_FUNC_ALIAS(memcpy, __memcpy)
> +#else
> +SYM_FUNC_ALIAS_WEAK(memcpy, __memcpy)
> +#endif
> EXPORT_SYMBOL(memcpy)
>
> SYM_FUNC_START_LOCAL(memcpy_orig)
> diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
> index 02661861e5dd9..3b1a02357fb29 100644
> --- a/arch/x86/lib/memmove_64.S
> +++ b/arch/x86/lib/memmove_64.S
> @@ -215,5 +215,9 @@ SYM_FUNC_START(__memmove)
> SYM_FUNC_END(__memmove)
> EXPORT_SYMBOL(__memmove)
>
> +#ifdef CONFIG_GENERIC_ENTRY
> SYM_FUNC_ALIAS(memmove, __memmove)
> +#else
> +SYM_FUNC_ALIAS_WEAK(memmove, __memmove)
> +#endif
> EXPORT_SYMBOL(memmove)
> diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
> index 7c59a704c4584..fe27538a355db 100644
> --- a/arch/x86/lib/memset_64.S
> +++ b/arch/x86/lib/memset_64.S
> @@ -40,7 +40,11 @@ SYM_FUNC_START(__memset)
> SYM_FUNC_END(__memset)
> EXPORT_SYMBOL(__memset)
>
> +#ifdef CONFIG_GENERIC_ENTRY
> SYM_FUNC_ALIAS(memset, __memset)
> +#else
> +SYM_FUNC_ALIAS_WEAK(memset, __memset)
> +#endif
> EXPORT_SYMBOL(memset)
>
> SYM_FUNC_START_LOCAL(memset_orig)
>
> ---
> base-commit: 9561de3a55bed6bdd44a12820ba81ec416e705a7
> change-id: 20230609-uml-kasan-2392dd4c3858
>
> Best regards,
> --
> Vincent Whitchurch <vincent.whitchurch@axis.com>
>
> --
> You received this message because you are subscribed to the Google Groups "kasan-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to kasan-dev+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/20230609-uml-kasan-v1-1-5fac8d409d4f%40axis.com.
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4003 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] x86: Fix build of UML with KASAN
2023-06-10 8:34 ` David Gow
@ 2023-09-11 7:26 ` Vincent Whitchurch
2023-09-11 7:43 ` Richard Weinberger
0 siblings, 1 reply; 5+ messages in thread
From: Vincent Whitchurch @ 2023-09-11 7:26 UTC (permalink / raw)
To: Vincent Whitchurch, davidgow@google.com, x86@kernel.org
Cc: dave.hansen@linux.intel.com, kernel, rafael.j.wysocki@intel.com,
linux-kernel@vger.kernel.org, johannes@sipsolutions.net,
mingo@redhat.com, linux-um@lists.infradead.org,
tglx@linutronix.de, andreyknvl@gmail.com,
anton.ivanov@cambridgegreys.com, dvyukov@google.com,
richard@nod.at, hpa@zytor.com, peterz@infradead.org,
ryabinin.a.a@gmail.com, frederic@kernel.org, bp@alien8.de,
glider@google.com, vincenzo.frascino@arm.com,
kasan-dev@googlegroups.com
On Sat, 2023-06-10 at 16:34 +0800, David Gow wrote:
> On Fri, 9 Jun 2023 at 19:19, Vincent Whitchurch
> <vincent.whitchurch@axis.com> wrote:
> >
> > Building UML with KASAN fails since commit 69d4c0d32186 ("entry, kasan,
> > x86: Disallow overriding mem*() functions") with the following errors:
> >
> > $ tools/testing/kunit/kunit.py run --kconfig_add CONFIG_KASAN=y
> > ...
> > ld: mm/kasan/shadow.o: in function `memset':
> > shadow.c:(.text+0x40): multiple definition of `memset';
> > arch/x86/lib/memset_64.o:(.noinstr.text+0x0): first defined here
> > ld: mm/kasan/shadow.o: in function `memmove':
> > shadow.c:(.text+0x90): multiple definition of `memmove';
> > arch/x86/lib/memmove_64.o:(.noinstr.text+0x0): first defined here
> > ld: mm/kasan/shadow.o: in function `memcpy':
> > shadow.c:(.text+0x110): multiple definition of `memcpy';
> > arch/x86/lib/memcpy_64.o:(.noinstr.text+0x0): first defined here
> >
> > If I'm reading that commit right, the !GENERIC_ENTRY case is still
> > supposed to be allowed to override the mem*() functions, so use weak
> > aliases in that case.
> >
> > Fixes: 69d4c0d32186 ("entry, kasan, x86: Disallow overriding mem*() functions")
> > Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> > ---
>
> Thanks: I stumbled into this the other day and ran out of time to debug it.
>
> I've tested that it works here.
>
> Tested-by: David Gow <davidgow@google.com>
Thanks. Perhaps someone could pick this up? It's been a few months,
and the build problem is still present on v6.6-rc1.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] x86: Fix build of UML with KASAN
2023-09-11 7:26 ` Vincent Whitchurch
@ 2023-09-11 7:43 ` Richard Weinberger
0 siblings, 0 replies; 5+ messages in thread
From: Richard Weinberger @ 2023-09-11 7:43 UTC (permalink / raw)
To: Vincent Whitchurch
Cc: davidgow, x86, dave hansen, kernel, rafael j wysocki,
linux-kernel, Johannes Berg, mingo, linux-um, tglx, andreyknvl,
anton ivanov, Dmitry Vyukov, hpa, Peter Zijlstra, ryabinin a a,
frederic, bp, Alexander Potapenko, Vincenzo Frascino, kasan-dev
----- Ursprüngliche Mail -----
> Von: "Vincent Whitchurch" <Vincent.Whitchurch@axis.com>
>> Thanks: I stumbled into this the other day and ran out of time to debug it.
>>
>> I've tested that it works here.
>>
>> Tested-by: David Gow <davidgow@google.com>
>
> Thanks. Perhaps someone could pick this up? It's been a few months,
> and the build problem is still present on v6.6-rc1.
I'll happily carry it though the UML tree if we get an ACK from x86 maintainers.
Thanks,
//richard
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86: Fix build of UML with KASAN
2023-06-09 11:18 [PATCH] x86: Fix build of UML with KASAN Vincent Whitchurch
2023-06-10 8:34 ` David Gow
@ 2023-09-11 8:56 ` Peter Zijlstra
1 sibling, 0 replies; 5+ messages in thread
From: Peter Zijlstra @ 2023-09-11 8:56 UTC (permalink / raw)
To: Vincent Whitchurch
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Frederic Weisbecker, Rafael J. Wysocki,
Richard Weinberger, Anton Ivanov, Johannes Berg, linux-um,
Andrey Ryabinin, Alexander Potapenko, Andrey Konovalov,
Dmitry Vyukov, Vincenzo Frascino, kasan-dev, linux-kernel, kernel
On Fri, Jun 09, 2023 at 01:18:54PM +0200, Vincent Whitchurch wrote:
> Building UML with KASAN fails since commit 69d4c0d32186 ("entry, kasan,
> x86: Disallow overriding mem*() functions") with the following errors:
>
> $ tools/testing/kunit/kunit.py run --kconfig_add CONFIG_KASAN=y
> ...
> ld: mm/kasan/shadow.o: in function `memset':
> shadow.c:(.text+0x40): multiple definition of `memset';
> arch/x86/lib/memset_64.o:(.noinstr.text+0x0): first defined here
> ld: mm/kasan/shadow.o: in function `memmove':
> shadow.c:(.text+0x90): multiple definition of `memmove';
> arch/x86/lib/memmove_64.o:(.noinstr.text+0x0): first defined here
> ld: mm/kasan/shadow.o: in function `memcpy':
> shadow.c:(.text+0x110): multiple definition of `memcpy';
> arch/x86/lib/memcpy_64.o:(.noinstr.text+0x0): first defined here
>
> If I'm reading that commit right, the !GENERIC_ENTRY case is still
> supposed to be allowed to override the mem*() functions, so use weak
> aliases in that case.
>
> Fixes: 69d4c0d32186 ("entry, kasan, x86: Disallow overriding mem*() functions")
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> ---
> arch/x86/lib/memcpy_64.S | 4 ++++
> arch/x86/lib/memmove_64.S | 4 ++++
> arch/x86/lib/memset_64.S | 4 ++++
> 3 files changed, 12 insertions(+)
>
> diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
> index 8f95fb267caa7..5dc265b36ef0b 100644
> --- a/arch/x86/lib/memcpy_64.S
> +++ b/arch/x86/lib/memcpy_64.S
> @@ -40,7 +40,11 @@ SYM_TYPED_FUNC_START(__memcpy)
> SYM_FUNC_END(__memcpy)
> EXPORT_SYMBOL(__memcpy)
>
> +#ifdef CONFIG_GENERIC_ENTRY
> SYM_FUNC_ALIAS(memcpy, __memcpy)
> +#else
> +SYM_FUNC_ALIAS_WEAK(memcpy, __memcpy)
> +#endif
> EXPORT_SYMBOL(memcpy)
>
> SYM_FUNC_START_LOCAL(memcpy_orig)
Urgh...
Can we use CONFIG_UML here to clarify things? It's a bit of a bother UML
is diverging to much, but oh well.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-09-11 21:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-09 11:18 [PATCH] x86: Fix build of UML with KASAN Vincent Whitchurch
2023-06-10 8:34 ` David Gow
2023-09-11 7:26 ` Vincent Whitchurch
2023-09-11 7:43 ` Richard Weinberger
2023-09-11 8:56 ` Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox