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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 DD71CC4727C for ; Thu, 1 Oct 2020 15:26:36 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 73B7120872 for ; Thu, 1 Oct 2020 15:26:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="0N3SZv0h"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="XEVoiK4k" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73B7120872 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+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=merlin.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=yZc1M4NdLlOGSI1PpLC8aX5zKPvVGxHP12IYJ7b2yDs=; b=0N3SZv0hTqNhhlZ3iC/kys238 axCfzjrmskwPte0b38bARefZtizm6d0uJWy7CrrqXCJ6mN/LViLlQbrDMSOw+m7p2ARSNpQHhQ50+ 9P7tI5mUijWHIxJyxuZ0/OLhW7o2QvV3PEUFkulOAF0yOXKZdKugLmg0zMCfULEHXTzYY0rnzYXBA p+ToPTVbJz/Lt0K7gW2xzvzdfXfhS2Quy8zBdomSSZPOqJ7Gd5Uf1ypJTzrrRdTJ2CCzQQBCC8XPB JQj5M2Qr82TXrXw8USe9pL52IB5l5mCBpF/jLKaI6QZLoalPLlbrYtU2MShkUCKw3IS91y0AFX15I JsR6EwPPg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kO0RZ-0001Ac-5P; Thu, 01 Oct 2020 15:24:29 +0000 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kO0Py-0000IK-Ln for linux-arm-kernel@lists.infradead.org; Thu, 01 Oct 2020 15:22:59 +0000 Received: by mail-lj1-x243.google.com with SMTP id k25so4987103ljg.9 for ; Thu, 01 Oct 2020 08:22:50 -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=fvoVo/AlK8YyGNVarOwLDRqDnwOyPvSHJNcg2HWaJGI=; b=XEVoiK4kf0cX0mlS5/7up0sDACxxEvidVGsmUukhiwCRhf9Pk6Q8fBkM36+t8f51qg sMQ3GAR1ZiI8T/qoLI6ZeuA9L0xBrlDURLakQi6OxjzSUf/qRNovA0EwEGoVrjCq0VY4 oVrNbJZitacLgfmkZk30+MqEF92ONHjzv+y2UMhCVZMG/IWEYNNxVQxkvO+E0K/4JTzO MKylTe4M4WIKo0+u4Cxb4uzpFuKhvmIYCxxsdLN8yB3b9OG3xynToyJi3db4kqEEqq0j mghLUOaRglhzXD97Wu6Y7/HTQWFcT6jgXBrcPG0ov9h42pVsFzfIKb/QrUah8H0X2pbo tiNQ== 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=fvoVo/AlK8YyGNVarOwLDRqDnwOyPvSHJNcg2HWaJGI=; b=LSmpfBDLdM+Y7Ndgv3CtixK+oK9G1T2h71D6L2SeON/sS36QcbdfWC1u8taZEwxdUy 3b7f8SpqqUy4T7LdMeogSFvXwPu2qBKJOvAAWEgsRzDwv7D6FSlfw4bZQ5l/OWDj8HEG f4YDspn4X1m5ZECPPen+8x+f/3+vQ5d5na4Q79asaXkWTUs6kUYblyvmlaq5noPAhd9C SQS0mIe4kcB0+MJnd40nE2mpt+g/qNaf4Evorf4taTcCLgmxdokhXiChXuCJYwfSBxyC db+dwDS9WdaGnJ53evXU1mexpiO8Dj1kvYfWGXIaVtAPstxFoOVJ+ZOnjBSrIiNurcVv hHSQ== X-Gm-Message-State: AOAM532ov5MDvx4bXNely6k3oj70te1WP9VhtcUarT4n30uyg9gQSOYo HPpnuzMZqtQWMudg6fW1ouF0+Q== X-Google-Smtp-Source: ABdhPJxp2KtboidkFXcX6gu0rp8nKjGNlLDNJmfgfROnMTCX3BB62rAG844AdUyGrJFfk4LtUpOu/A== X-Received: by 2002:a05:651c:10cc:: with SMTP id l12mr2314455ljn.351.1601565769170; Thu, 01 Oct 2020 08:22:49 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id v18sm587578lfa.238.2020.10.01.08.22.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 08:22:48 -0700 (PDT) From: Linus Walleij To: Florian Fainelli , Abbott Liu , Russell King , Ard Biesheuvel , Andrey Ryabinin , Mike Rapoport Subject: [PATCH 2/6 v14] ARM: Disable KASan instrumentation for some code Date: Thu, 1 Oct 2020 17:22:28 +0200 Message-Id: <20201001152232.274367-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201001152232.274367-1-linus.walleij@linaro.org> References: <20201001152232.274367-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-20201001_112250_793552_59DDAE87 X-CRM114-Status: GOOD ( 21.72 ) 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+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 v13->v14: - Resend with the other patches ChangeLog v12->v13: - Rebase on kernel v5.9-rc1 ChangeLog v11->v12: - Resend with the other changes. ChangeLog v10->v11: - Resend with the other changes. 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 b1147b7f2c8d..362e17e37398 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 a54f70731d9f..171c3dcb5242 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.26.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel