From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68643C433E0 for ; Mon, 15 Jun 2020 09:13:10 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3C73E20679 for ; Mon, 15 Jun 2020 09:13:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="efckIMTu"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="SVb6Zt8V" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C73E20679 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IyxQu1gRcm48wSIxyowVkxjb0EoPn4MFiqMOTQvB6LQ=; b=efckIMTunOkUVl Pl59Q334yW8g4j3i/9J54132AqCQ4Z1hUts9NQ/TgFxQNje1R4K0hroZESlePIeFn+oxqcm99XOyC f3ELrPfqEs0rjGjlW99FixqNRRIHknXVCmIcbPpVg4AwIGJPGoaXrCcNHJA1U3/u7GjeQTSlEjZlG /6p0MGGTST8t064JiUyLT8vi9iU/ULBxVEiHvJbLLEb4bgULEOvX98kgIPYT/jfQef81h5B1/dqvE cDhJUJJJpBrnBM6Xi46M5sUEhPqM+0P8xQoUiVx4PSjLb4o/5it7yvQBj91S/DC98dprltNW2Jkgx 2xGAYIsLU4QFmM1yAxyQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jklAy-0003YH-Uz; Mon, 15 Jun 2020 09:13:08 +0000 Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jkl34-0000jZ-62 for linux-arm-kernel@lists.infradead.org; Mon, 15 Jun 2020 09:05:08 +0000 Received: by mail-lj1-x242.google.com with SMTP id i3so13682676ljg.3 for ; Mon, 15 Jun 2020 02:04:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Vlh54lde7Ac790L1VIZHjiID0UsLtjo+K5a58z7ZLwQ=; b=SVb6Zt8V09ycLr5rdEn6ubIbYxapl43fDTZhQGn2su74VJ6vvcaneKis79e4eH+x+U WiMbXR4/+/KLnt8WGIVviU+HKJumjitccD7Ljp38Npa7A77aLOjTl5E3lCYh4By8cxpY wcpGySt0U3Oz1AHdnfaR8TFxGKiaHda7bQ9OxNokf70y5cRHzoQCRMReHiCyStMzwaA6 5AT6PMJuPydwNKEwQ6rt4AlShfc47t8ToaMuMoVsLapRWoHYuL1gey8fq4nDGjl2nprT JvxkBFbzF0eDjobk2D+nWR57p0G7ASXp7u28p1fyxNndnruEh6pa3UY/9goP9puAcPIv 3Znw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Vlh54lde7Ac790L1VIZHjiID0UsLtjo+K5a58z7ZLwQ=; b=NX+zhElJgaYpE4kU4xh60jsCL3+DyNd49K5wwbZtng6u/XkgQgTEYBO0+2JVL97jM6 YgYKwxwHEcGKXjVaY1W0wZ3baGL0N4QwrBofzZiaIXq2uQtGFagdcKtpCAp1MnYTuBcl x36C83+zputoAW6V21la31/sC1yZHjobVApJ09m7yk7Vf9pDGdCRU4Obru7Z6eZbN/G9 IGF4dSDow9q9KhuAaKrAry5fn7DM/CwSuJTkAgjtzMCNDjbNg/o9b5+hGkwqdRFgEMP/ I8umYl9wJHZCvqz/LJbTlJ7AhxNiRZ4g6fMJvm7QYsF3Vjhl/YPnj8uPtlqUuZ5Synbr HLuw== X-Gm-Message-State: AOAM531/ml+ombmCyAATKqjrLKZBAI7Fz3yyXDptq9pZofnOCotiZj0V QYknX3kXZGtLXc6LSLfhb7GJqQ== X-Google-Smtp-Source: ABdhPJxa9HfguETSYg/akezpAs5brGvT0f3Se9J+3mrdFiP/ASbOu3gBa6mvBlqboMvL+dDWwAI7sQ== X-Received: by 2002:a2e:8055:: with SMTP id p21mr13502031ljg.80.1592211895609; Mon, 15 Jun 2020 02:04:55 -0700 (PDT) Received: from localhost.localdomain (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id c78sm5284434lfd.63.2020.06.15.02.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jun 2020 02:04:55 -0700 (PDT) From: Linus Walleij To: Florian Fainelli , Abbott Liu , Russell King , Ard Biesheuvel , Andrey Ryabinin , Mike Rapoport Subject: [PATCH 1/5 v10] ARM: Disable KASan instrumentation for some code Date: Mon, 15 Jun 2020 11:02:43 +0200 Message-Id: <20200615090247.5218-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200615090247.5218-1-linus.walleij@linaro.org> References: <20200615090247.5218-1-linus.walleij@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200615_020458_253291_1CBD51E0 X-CRM114-Status: GOOD ( 17.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arnd Bergmann , Marc Zyngier , Linus Walleij , kasan-dev@googlegroups.com, Alexander Potapenko , linux-arm-kernel@lists.infradead.org, Dmitry Vyukov Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Andrey Ryabinin Disable instrumentation for arch/arm/boot/compressed/* since that code is executed before the kernel has even set up its mappings and definately out of scope for KASan. Disable instrumentation of arch/arm/vdso/* because that code is not linked with the kernel image, so the KASan management code would fail to link. Disable instrumentation of arch/arm/mm/physaddr.c. See commit ec6d06efb0ba ("arm64: Add support for CONFIG_DEBUG_VIRTUAL") for more details. Disable kasan check in the function unwind_pop_register because it does not matter that kasan checks failed when unwind_pop_register() reads the stack memory of a task. Cc: Andrey Ryabinin Cc: Alexander Potapenko Cc: Dmitry Vyukov Cc: kasan-dev@googlegroups.com Reviewed-by: Ard Biesheuvel Tested-by: Ard Biesheuvel # QEMU/KVM/mach-virt/LPAE/8G Reported-by: Florian Fainelli Reported-by: Marc Zyngier Signed-off-by: Abbott Liu Signed-off-by: Florian Fainelli Signed-off-by: Linus Walleij --- ChangeLog v9->v10: - Rebase on v5.8-rc1 ChangeLog v8->v9: - Collect Ard's tags. ChangeLog v7->v8: - Do not sanitize arch/arm/mm/mmu.c. Apart from being intuitively correct, it turns out that KASan will insert a __asan_load4() into the set_pte_at() function in mmu.c and this is something that KASan calls in the early initialization, to set up the shadow memory. Naturally, __asan_load4() cannot be called before the shadow memory is set up so we need to exclude mmu.c from sanitization. ChangeLog v6->v7: - Removed the KVM instrumentaton disablement since KVM on ARM32 is gone. --- arch/arm/boot/compressed/Makefile | 1 + arch/arm/kernel/unwind.c | 6 +++++- arch/arm/mm/Makefile | 2 ++ arch/arm/vdso/Makefile | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile index 00602a6fba04..bb8d193d13de 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -24,6 +24,7 @@ OBJS += hyp-stub.o endif GCOV_PROFILE := n +KASAN_SANITIZE := n # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. KCOV_INSTRUMENT := n diff --git a/arch/arm/kernel/unwind.c b/arch/arm/kernel/unwind.c index d2bd0df2318d..f35eb584a18a 100644 --- a/arch/arm/kernel/unwind.c +++ b/arch/arm/kernel/unwind.c @@ -236,7 +236,11 @@ static int unwind_pop_register(struct unwind_ctrl_block *ctrl, if (*vsp >= (unsigned long *)ctrl->sp_high) return -URC_FAILURE; - ctrl->vrs[reg] = *(*vsp)++; + /* Use READ_ONCE_NOCHECK here to avoid this memory access + * from being tracked by KASAN. + */ + ctrl->vrs[reg] = READ_ONCE_NOCHECK(*(*vsp)); + (*vsp)++; return URC_OK; } diff --git a/arch/arm/mm/Makefile b/arch/arm/mm/Makefile index 7cb1699fbfc4..99699c32d8a5 100644 --- a/arch/arm/mm/Makefile +++ b/arch/arm/mm/Makefile @@ -7,6 +7,7 @@ obj-y := extable.o fault.o init.o iomap.o obj-y += dma-mapping$(MMUEXT).o obj-$(CONFIG_MMU) += fault-armv.o flush.o idmap.o ioremap.o \ mmap.o pgd.o mmu.o pageattr.o +KASAN_SANITIZE_mmu.o := n ifneq ($(CONFIG_MMU),y) obj-y += nommu.o @@ -16,6 +17,7 @@ endif obj-$(CONFIG_ARM_PTDUMP_CORE) += dump.o obj-$(CONFIG_ARM_PTDUMP_DEBUGFS) += ptdump_debugfs.o obj-$(CONFIG_MODULES) += proc-syms.o +KASAN_SANITIZE_physaddr.o := n obj-$(CONFIG_DEBUG_VIRTUAL) += physaddr.o obj-$(CONFIG_ALIGNMENT_TRAP) += alignment.o diff --git a/arch/arm/vdso/Makefile b/arch/arm/vdso/Makefile index d3c9f03e7e79..71d18d59bd35 100644 --- a/arch/arm/vdso/Makefile +++ b/arch/arm/vdso/Makefile @@ -42,6 +42,8 @@ GCOV_PROFILE := n # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. KCOV_INSTRUMENT := n +KASAN_SANITIZE := n + # Force dependency $(obj)/vdso.o : $(obj)/vdso.so -- 2.25.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel