Message ID | 20230609-uml-kasan-v1-1-5fac8d409d4f@axis.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp884743vqr; Fri, 9 Jun 2023 04:49:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4oWsuNrpa//uKH5uSqM1Nfq/5emWlU1q2IaNRD5SHNzJMvECMOJzRTfk9H8mcqhaCmBnoH X-Received: by 2002:a05:6a20:7f8c:b0:116:fd37:c924 with SMTP id d12-20020a056a207f8c00b00116fd37c924mr1114751pzj.5.1686311363364; Fri, 09 Jun 2023 04:49:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686311363; cv=none; d=google.com; s=arc-20160816; b=CchKpo52GKLEK06N35qxD3D4/saycO2tM4NDlQI/82IvBlvV64W5OAUqd/ohhEVlJT V8xUEjIMm75lVtCWKbmY6Vwu1/0b3lnYK+7m4eA7uD/lE4OPxqMPubxHbtN10LFu6Weo 6GySq4wqLwX87v3h+pVaX0cqRUPJ9W5T6PO9u6ESJlIeVf6FnKJLYjluYfygCHXDAS4L CgaWqIqrpK6QFc23byqRd6q4Yq0XFpacpEqrvVIid+6ySVelOv35X0Bi4bogAow9SZDj Kgjkyx9rQse2bYZa/eeyfngpvN0jXscwMtXwfpiGzgWf3k0LJMDVCBZQLO4Rw9CR2f5Q rnmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=7XMigKyzIzkGYn81G4evNo2KHPOOkw2Qm++AiRLE9eM=; b=dejUBUIVDt2Wr0TzfNMe8nC12ozKRcYXm9oSf5bwjL2D6IEUb4K7koo1pLF1EuHwUn PikgLVCjTBDYaa6p/dtnRZi7Eeo58YhdlHLY1dx73S8Tqr3mOQztrjcwB5+nj8+YFTtV FNXaPKcyDEyEekp3ljPaFcO1vexE0HfvRid6FjTZ1lBllgS7A87PyCqRdatuhn01q9QI o9T57o6yh0siKalSgaITCvLAmZQudOvmMZwxC5wXp0U8sSFs63Jya+VO/slsbs1tFtRP xIQ4WXi72sBzprlQDReeR4HcD0DxGwRJjyB6CKAEodz07IX3cQrrzAJuq5kK8qo/EMOr m4zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=bgBKpe26; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i191-20020a636dc8000000b0053f3d04e66bsi2519740pgc.698.2023.06.09.04.49.09; Fri, 09 Jun 2023 04:49:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=bgBKpe26; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238291AbjFILTI (ORCPT <rfc822;liningstudo@gmail.com> + 99 others); Fri, 9 Jun 2023 07:19:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229808AbjFILTE (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 9 Jun 2023 07:19:04 -0400 Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAD73C1 for <linux-kernel@vger.kernel.org>; Fri, 9 Jun 2023 04:19:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1686309542; x=1717845542; h=from:date:subject:mime-version:content-transfer-encoding: message-id:to:cc; bh=7XMigKyzIzkGYn81G4evNo2KHPOOkw2Qm++AiRLE9eM=; b=bgBKpe26ymYsevpWU8ZM/ybAdNsG47TSnm5L3ZpCqsyreDNiwZxVOhbf YJG/3BzBKBhGydzVuHmrQAVmG8fkIZEaX5QT4EitqUeN4slbbR1vQMQCh YEDZZCps0PQ5bW02phKFY9On+3QppH8V+euHiqguQBldqjmunLY9n578O 5Zwgq47FgBc8i2fFF2ZXrHjbyndlWLpUECEkFlcVddjV0StXz/Fz/UKMl LTbntvNkNhfq2KpYuPOWo0E8XM09wP66rhVgn7sBigoZzeMLY2vS4Ls1a gV7MZiPlKD/5/JRr1i1zqp3FLfjCk8TKDH5U0N37gi3vEjYdm3ORH+43a w==; From: Vincent Whitchurch <vincent.whitchurch@axis.com> Date: Fri, 9 Jun 2023 13:18:54 +0200 Subject: [PATCH] x86: Fix build of UML with KASAN MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: <20230609-uml-kasan-v1-1-5fac8d409d4f@axis.com> X-B4-Tracking: v=1; b=H4sIAJ0Kg2QC/x2N0QrCMAxFf2Xk2UBNnWz+iviQtZkLm600KMLYv 9vt8VzO5axgUlQMbs0KRb5qmlOF86mBMHF6CmqsDOTIu6vr8fNacGbjhOR7ivESfNd2UP2BTXA onMK0P8acaZ/fRUb9HYn7Y9v+0FOpHXIAAAA= To: Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, <x86@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>, Frederic Weisbecker <frederic@kernel.org>, "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>, Peter Zijlstra <peterz@infradead.org> CC: Richard Weinberger <richard@nod.at>, Anton Ivanov <anton.ivanov@cambridgegreys.com>, Johannes Berg <johannes@sipsolutions.net>, <linux-um@lists.infradead.org>, Andrey Ryabinin <ryabinin.a.a@gmail.com>, Alexander Potapenko <glider@google.com>, Andrey Konovalov <andreyknvl@gmail.com>, Dmitry Vyukov <dvyukov@google.com>, Vincenzo Frascino <vincenzo.frascino@arm.com>, <kasan-dev@googlegroups.com>, <linux-kernel@vger.kernel.org>, <kernel@axis.com>, Vincent Whitchurch <vincent.whitchurch@axis.com> X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768225624163011173?= X-GMAIL-MSGID: =?utf-8?q?1768225624163011173?= |
Series |
x86: Fix build of UML with KASAN
|
|
Commit Message
Vincent Whitchurch
June 9, 2023, 11:18 a.m. UTC
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(+)
---
base-commit: 9561de3a55bed6bdd44a12820ba81ec416e705a7
change-id: 20230609-uml-kasan-2392dd4c3858
Best regards,
Comments
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.
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)