From patchwork Thu Sep 17 09:38:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Ryabinin X-Patchwork-Id: 7204331 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 87E88BEEC1 for ; Thu, 17 Sep 2015 09:40:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9A2E620824 for ; Thu, 17 Sep 2015 09:40:42 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C0B452081F for ; Thu, 17 Sep 2015 09:40:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZcVel-0003dU-3F; Thu, 17 Sep 2015 09:39:07 +0000 Received: from mail-lb0-x236.google.com ([2a00:1450:4010:c04::236]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZcVeQ-00038z-0T for linux-arm-kernel@lists.infradead.org; Thu, 17 Sep 2015 09:38:47 +0000 Received: by lbpo4 with SMTP id o4so6232114lbp.2 for ; Thu, 17 Sep 2015 02:38:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qGXE01ULLnhGcKfWVa0cl2S8Zzz/dEJQgPW+FcczWkU=; b=aZHkha37DRcR+R+PYe2ZrMf77kVX5FVYPTXj4Y+hMn7KyalB1vN5gJOcEAZUjyblvZ XRMOE8m83SLRGV4CGxBrzw0fgoa4T274FEsj/bO8BMlFEZfSL5BWS4t+aKp2Hfv4ucql PsCjGrmWYT91V3MMnqC0uvHVm/u6MWCqGJjXQa8ytNCV8HD912rcWCqoQ/RVRd1CUQk5 iQh+NexdYROH9qTox1UxgoTjs592UotjpXcdV73ZP1BpWf7A2UOSedQ4u68hkshv8tWH Sn6z7Et2pT82ZaHb7DGmTC+nb75gCn45Ks53y2kn+oc0xaUjA/it5HkgKbDU7op7yJku CBpA== X-Received: by 10.112.129.72 with SMTP id nu8mr35039451lbb.81.1442482703989; Thu, 17 Sep 2015 02:38:23 -0700 (PDT) Received: from localhost.sw.ru (swsoft-msk-nat.sw.ru. [195.214.232.10]) by smtp.gmail.com with ESMTPSA id b10sm410402laf.16.2015.09.17.02.38.19 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 17 Sep 2015 02:38:19 -0700 (PDT) From: Andrey Ryabinin To: Will Deacon , Catalin Marinas , linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 3/6] x86, efi, kasan: #undef memset/memcpy/memmove per arch. Date: Thu, 17 Sep 2015 12:38:09 +0300 Message-Id: <1442482692-6416-4-git-send-email-ryabinin.a.a@gmail.com> X-Mailer: git-send-email 2.4.6 In-Reply-To: <1442482692-6416-1-git-send-email-ryabinin.a.a@gmail.com> References: <1442482692-6416-1-git-send-email-ryabinin.a.a@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150917_023846_289517_B430C217 X-CRM114-Status: GOOD ( 12.07 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Matt Fleming , Yury , Alexey Klimov , Arnd Bergmann , linux-mm@kvack.org, linux-efi@vger.kernel.org, Andrey Konovalov , Linus Walleij , x86@kernel.org, linux-kernel@vger.kernel.org, David Keitel , Andrey Ryabinin , Alexander Potapenko , "H. Peter Anvin" , Thomas Gleixner , fengguang.wu@intel.com, Ingo Molnar , Dmitry Vyukov MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In not-instrumented code KASAN replaces instrumented memset/memcpy/memmove with not-instrumented analogues __memset/__memcpy/__memove. However, on x86 the EFI stub is not linked with the kernel. It uses not-instrumented mem*() functions from arch/x86/boot/compressed/string.c So we don't replace them with __mem*() variants in EFI stub. On ARM64 the EFI stub is linked with the kernel, so we should replace mem*() functions with __mem*(), because the EFI stub runs before KASAN sets up early shadow. So let's move these #undef mem* into arch's asm/efi.h which is also included by the EFI stub. Also, this will fix the warning in 32-bit build reported by kbuild test robot : efi-stub-helper.c:599:2: warning: implicit declaration of function 'memcpy' Signed-off-by: Andrey Ryabinin --- arch/x86/include/asm/efi.h | 12 ++++++++++++ drivers/firmware/efi/libstub/efistub.h | 4 ---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h index 155162e..6db2742 100644 --- a/arch/x86/include/asm/efi.h +++ b/arch/x86/include/asm/efi.h @@ -86,6 +86,18 @@ extern u64 asmlinkage efi_call(void *fp, ...); extern void __iomem *__init efi_ioremap(unsigned long addr, unsigned long size, u32 type, u64 attribute); +/* + * CONFIG_KASAN may redefine memset to __memset. + * __memset function is present only in kernel binary. + * Since the EFI stub linked into a separate binary it + * doesn't have __memset(). So we should use standard + * memset from arch/x86/boot/compressed/string.c + * The same applies to memcpy and memmove. + */ +#undef memcpy +#undef memset +#undef memmove + #endif /* CONFIG_X86_32 */ extern struct efi_scratch efi_scratch; diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h index e334a01..6b6548f 100644 --- a/drivers/firmware/efi/libstub/efistub.h +++ b/drivers/firmware/efi/libstub/efistub.h @@ -5,10 +5,6 @@ /* error code which can't be mistaken for valid address */ #define EFI_ERROR (~0UL) -#undef memcpy -#undef memset -#undef memmove - void efi_char16_printk(efi_system_table_t *, efi_char16_t *); efi_status_t efi_open_volume(efi_system_table_t *sys_table_arg, void *__image,