From patchwork Fri Aug 28 11:09:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Ryabinin X-Patchwork-Id: 7091161 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 79873BEEC1 for ; Fri, 28 Aug 2015 11:14:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BF94120998 for ; Fri, 28 Aug 2015 11:13:59 +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 E83C12099A for ; Fri, 28 Aug 2015 11:13:58 +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 1ZVHYB-0001mt-1b; Fri, 28 Aug 2015 11:10:27 +0000 Received: from mail-lb0-x22d.google.com ([2a00:1450:4010:c04::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZVHY8-0000cK-UP for linux-arm-kernel@lists.infradead.org; Fri, 28 Aug 2015 11:10:25 +0000 Received: by lbcbn3 with SMTP id bn3so27947748lbc.2 for ; Fri, 28 Aug 2015 04:10:02 -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=Ft4uKsiauQSLCRGpdTBo7uBkcD5zaSw8uxWmZGayhqw=; b=ZFapPHRxztRNa9xWQRbGCNoU3n+z3VmrdlNh5+tdxZnmdu8JF4PWahdYTwun/q5fjg /nu0uy8RRciltoyJQC8F1LE8jht5U4ivw+DsdXNoJP/tlP+FkQKPFj5a/xNUS4C5Lfrl 9driq+Q3vsuC2UWjQnMDfhIXdtSbXoIVC0IpQ33NQLoAt26kvq+Qo5aT3tK+BNdeDrv2 0mZUaecTt9y8vyCnwoBhMExp8tyWDDGGm7OO+0Wxb6SI+SlOmHL3FRbz60twWEiWevjF bFtIdiybwYof2lcDaYak+xGUi/43ppHv1qTB8Cr4JGv6ASq9pkVqcsrJkAAsB+abvRv6 FoXg== X-Received: by 10.152.37.67 with SMTP id w3mr4521297laj.123.1440760201988; Fri, 28 Aug 2015 04:10:01 -0700 (PDT) Received: from localhost.sw.ru (swsoft-msk-nat.sw.ru. [195.214.232.10]) by smtp.gmail.com with ESMTPSA id kx11sm1314346lac.41.2015.08.28.04.10.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 28 Aug 2015 04:10:00 -0700 (PDT) From: Andrey Ryabinin To: Ingo Molnar , "H. Peter Anvin" , Thomas Gleixner , x86@kernel.org, Matt Fleming , linux-efi@vger.kernel.org Subject: [PATCH v2] x86, efi, kasan: #undef memset/memcpy/memmove per arch. Date: Fri, 28 Aug 2015 14:09:59 +0300 Message-Id: <1440760199-18111-1-git-send-email-ryabinin.a.a@gmail.com> X-Mailer: git-send-email 2.4.6 In-Reply-To: <20150828062745.GB1928@gmail.com> References: <20150828062745.GB1928@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150828_041025_172196_52AF0E25 X-CRM114-Status: GOOD ( 11.67 ) 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: Arnd Bergmann , Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org, Leif Lindholm , Andrey Ryabinin , Alexander Potapenko , linux-arm-kernel@lists.infradead.org, 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=-5.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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. Signed-off-by: Andrey Ryabinin --- arch/x86/include/asm/efi.h | 11 +++++++++++ drivers/firmware/efi/libstub/efistub.h | 4 ---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h index 155162e..6862f11 100644 --- a/arch/x86/include/asm/efi.h +++ b/arch/x86/include/asm/efi.h @@ -25,6 +25,17 @@ #define EFI32_LOADER_SIGNATURE "EL32" #define EFI64_LOADER_SIGNATURE "EL64" +/* + * Sometimes we may redefine memset to __memset. + * The EFI stub doesn't have __memset() because it's not + * linked with the kernel. 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 + #ifdef CONFIG_X86_32 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,