From patchwork Wed Aug 26 16:15:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Ryabinin X-Patchwork-Id: 7078391 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 8B323C0678 for ; Wed, 26 Aug 2015 16:17:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A4C472094C for ; Wed, 26 Aug 2015 16:17:37 +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 C75242094E for ; Wed, 26 Aug 2015 16:17:36 +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 1ZUdMO-0001Gj-QS; Wed, 26 Aug 2015 16:15:36 +0000 Received: from mail-la0-x22c.google.com ([2a00:1450:4010:c03::22c]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZUdMM-0001BF-Qc for linux-arm-kernel@lists.infradead.org; Wed, 26 Aug 2015 16:15:35 +0000 Received: by labgv11 with SMTP id gv11so55130912lab.2 for ; Wed, 26 Aug 2015 09:15:12 -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=+lMyfxffOb9R5yjpP7wuLovf7Q0YAGS1dzXJ/ozmb9U=; b=WxzqujK7psW+LXHTQVVLmH+2e8hRZ+3O8J0FvVhxfcdlKpvWrf3SJgc4mXqtTkKVS9 eoaYOcXp5auxntLgDrPVSkeB5RARRa1ceRNNZN07Epihz16lp51KoGPQpoycix1k9Irn 3e6kIIkhZBCxxbDRLeCrio63kIodF0m8D130ZKlR/wUk1ueS+EFWYXWfzimfkw+LWxSc 6hYe544MzKb45UaoOh8U6wynga3rDsi1ysYM/SiV0dnlsBjkNruRIpaZ9eTC4Z/YvHtZ 0lHXBcut3Nn4/Ml/6n+4Y6r/YLujvUBiqqsuW+fZrI0n74WhJ1m0HEZ9hje1lN2mtEZs exRQ== X-Received: by 10.112.87.69 with SMTP id v5mr32079174lbz.12.1440605711952; Wed, 26 Aug 2015 09:15:11 -0700 (PDT) Received: from localhost.sw.ru (swsoft-msk-nat.sw.ru. [195.214.232.10]) by smtp.gmail.com with ESMTPSA id ad1sm6866031lbc.5.2015.08.26.09.15.10 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 26 Aug 2015 09:15:11 -0700 (PDT) From: Andrey Ryabinin To: Will Deacon , Catalin Marinas , linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/4] x86, efi, kasan: #undef memset/memcpy/memmove per arch. Date: Wed, 26 Aug 2015 19:15:04 +0300 Message-Id: <1440605707-8325-2-git-send-email-ryabinin.a.a@gmail.com> X-Mailer: git-send-email 2.4.6 In-Reply-To: <1440605707-8325-1-git-send-email-ryabinin.a.a@gmail.com> References: <1440605707-8325-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-20150826_091535_053470_C751DFB7 X-CRM114-Status: GOOD ( 11.10 ) 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: linux-efi@vger.kernel.org, Andrey Ryabinin , Arnd Bergmann , Linus Walleij , "maintainer:X86 ARCHITECTURE 32-BIT AND 64-BIT" , linux-kernel@vger.kernel.org, Matt Fleming , Alexander Potapenko , "H. Peter Anvin" , Thomas Gleixner , 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=-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=ham 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 EFI stub is not linked with 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. In ARM64 EFI stub is linked with the kernel, so we should replace mem*() functions with __mem*(), because EFI stub runs before KASAN setup early shadow. So let's move these #undef mem* into arch's asm/efi.h which is also included by EFI stub. Signed-off-by: Andrey Ryabinin --- arch/x86/include/asm/efi.h | 8 ++++++++ drivers/firmware/efi/libstub/efistub.h | 4 ---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h index 155162e..d821ce2 100644 --- a/arch/x86/include/asm/efi.h +++ b/arch/x86/include/asm/efi.h @@ -25,6 +25,14 @@ #define EFI32_LOADER_SIGNATURE "EL32" #define EFI64_LOADER_SIGNATURE "EL64" +/* + * Use memcpy/memset from arch/x86/boot/compressed/string.c + * for EFI stub. + */ +#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,