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 0F2EDC433E7 for ; Mon, 19 Oct 2020 08:44:06 +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 8D1A92225A for ; Mon, 19 Oct 2020 08:44:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pa0ROPNJ"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="vOykgeZE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D1A92225A 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=okFeBfuhXUvaQU6cgWbi17w1V4Kdg15n1iAdwV84v18=; b=pa0ROPNJb/PjJeZaUd1+5xhQi G4nyhR2azndu4whX1rtFmrA8X5eqRTCpZd3O23jRaXfMYkaSaqoV1LgBp7/M6iUpeaTJiAo47w61k bDoTIQWBsX6hcMrHVWAwsb22BGr4iKHrc0FasKjmrNHcZWtGFC4cAUqjlcfAukBBXIkAFbyIWJxT2 gURPGBgjtAhTtIpVdR5UkZn8Ruf8+PPAOtwo9AyN/cZ49z5/ke83IGaKT80Z9Ld27t/zZMokXi9pn IaVN8uK5UT0/pamArvLO6tPMpJJ7Kx4DAtvNcgiJGKWfRSZ5MnDIHl6CiBl9oqcvvcvKfpz5NdjSa 8iGvJEFtA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kUQkB-0007Ev-Bh; Mon, 19 Oct 2020 08:42:16 +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 1kUQjp-00076K-So for linux-arm-kernel@lists.infradead.org; Mon, 19 Oct 2020 08:41:55 +0000 Received: by mail-lj1-x243.google.com with SMTP id i2so11004861ljg.4 for ; Mon, 19 Oct 2020 01:41:53 -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=Z5rl+dr93qvAjAtOmOIYI3mLkiuQrNK/hBohXcBcUbI=; b=vOykgeZE8nGTwy45VJUeCDK5WXzyMJw2oDrz3VWDdUOo8tnsNelJq+3zWJRhGPIsih JK+xSihjQSVdGinimZ+3RuvpfS+/LYeODbrvKZtp45dMZLh0yDAVNyMWoBQVFDKq4Dgn fKbZBZhmyCIu/i/YBJfnNGyfO3dSVmNwHejrSjLaf4iFX1OmuSrdxm+QHej5p73uGc8y wVsA22oWUbHoxvILaE3hNbknM8O7KSI9e+1YRVA2gtoEamnqYYimTds2xXKl7rMuaKug ITAH7qwQ8Nzae0c89vubRPhhGMdEgzI5BXV/w+gOWLbx4tDuGx2Ui+6Siybhg0pwVi58 IejQ== 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=Z5rl+dr93qvAjAtOmOIYI3mLkiuQrNK/hBohXcBcUbI=; b=ObGI3L7wcaXKAWp6/WrH+MToSkdJI2A46ONCcYILaIEEDHt0+vZ+LhLrlzUjgBgQS4 6COToNbTASjuF2SQ4n+YP3LZ4iMoUx45reMRo25xI+dBAnrTGMQYu32lNwuO8Jp2UOyv ivDGHAS0io1gmHtYie9UenGGMH2M7YDeSAonOlY/AK3PhnIMklbMMKFghpCvzWc4Rt2a st2+UfqIu2+N1aDnC5TwWKJ55eGpGcmXbmQmc+dEaJkImdU4s1Df448gZ1QBPcSeswEJ S9og99Js4AJdsilOFSG5zBpyfFGVYZUWsIah7GcujWNoU9KkGVhJsCgGstR9oJ925ZeV E82A== X-Gm-Message-State: AOAM5303fE0BEmxS0CRongE79BIe147cdBbCJLWuzM3/OQDK2ry+0TfK saHAKFOJI80zbdsgB0/1Gac9lw== X-Google-Smtp-Source: ABdhPJxkRy7pBFyb/OjAB/VMnOE0ASyCRe65UhtApTMw7F6kl5joyoSERKShPK5i7pAVm6x6NBjDwQ== X-Received: by 2002:a2e:b5c1:: with SMTP id g1mr5747865ljn.305.1603096912051; Mon, 19 Oct 2020 01:41:52 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id b18sm3174795lfp.89.2020.10.19.01.41.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2020 01:41:51 -0700 (PDT) From: Linus Walleij To: Florian Fainelli , Abbott Liu , Russell King , Ard Biesheuvel , Andrey Ryabinin , Mike Rapoport Subject: [PATCH 1/5 v16] ARM: Disable KASan instrumentation for some code Date: Mon, 19 Oct 2020 10:41:36 +0200 Message-Id: <20201019084140.4532-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201019084140.4532-1-linus.walleij@linaro.org> References: <20201019084140.4532-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-20201019_044153_972011_8B90450D X-CRM114-Status: GOOD ( 22.27 ) 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: Ahmad Fatoum , 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 Tested-by: Florian Fainelli # Brahma SoCs Tested-by: Ahmad Fatoum # i.MX6Q Reported-by: Florian Fainelli Reported-by: Marc Zyngier Signed-off-by: Abbott Liu Signed-off-by: Florian Fainelli Signed-off-by: Linus Walleij --- ChangeLog v15->v16: - Collect Florian's Tested-by - Resend with the other patches ChangeLog v14->v15: - Resend with the other patches 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