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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id CD883C19F2A for ; Mon, 8 Aug 2022 01:33:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DklYnBduBwiCj2uCJuLSobhlzPb0uWbbJ1+6h6cqBRA=; b=P2ALfDdFLooFBG PZrKmhm+6fncPPn2yQ39PhhbGUlNFphtBI9O7S+Y9y29ZRbd3LNW4PcgQsz7ydfJkJuNAYIXDnjFH 8DpwiafnTi5xGeZVum7EOWTFy2nG/TfYBgxIBkg9MQb8dDHVhaerqWjwFQPWW5cjxbOuzgcYwcMFa iEmCPdNVr0aVZXWxV1ccGOVXWXnpIYh6CSCQ5IfX9iJ2D+w0E50UbgFEu4HYWsLU+rwt71q/gg8lX vGiLdeWatxHzaU9BpFDUN4+X6AwkV9YjK0PYskxnNMOcrmUfq3ko85R5PwI5OcUMSxqgDtQZbJCTb D2oGSBxI8TVRetYRCkrw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oKrcH-007bLe-JB; Mon, 08 Aug 2022 01:31:37 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oKrcE-007bL5-Ja for linux-arm-kernel@lists.infradead.org; Mon, 08 Aug 2022 01:31:36 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0D67360DB9; Mon, 8 Aug 2022 01:31:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80CF6C433C1; Mon, 8 Aug 2022 01:31:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659922293; bh=GUDAZS/+eUIcCGBBfhfW4KeWzTJXZXRYQZKOZTAGzHc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m8HMRgg9xn7XTiW5ZK9p3LVXQHz5ppFZfw3tE+n+KEn1w0xXZBg3DsZvIWEfnJFj7 dt3eIcQk3Ty4JnMU3IraRzCTfjv0QDbuaY8GzS1NOj10iLGuOhgOOKGUyDPYVPSMOx f/WuSeB556oxfSFWOBz/Hlw9vrHlkWy092IklG/aV4w7IXIY8BiEe6kGdatCGcg7VB aWuOJI63cgRwNhxJbhjlkWwAbmYNjusomSl68FElDCeSSyxrVW4WBk2olPDGwGz13Z VJgsEk/G18/lTwZ9suRoGFlEGqTHex2AiCdyJ6hjdmlpTKNuF8xl90sDOjdg9+x7B6 DYD5HQ0wpDQmw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Andrey Konovalov , Mark Rutland , Will Deacon , Sasha Levin , catalin.marinas@arm.com, broonie@kernel.org, keescook@chromium.org, joey.gouly@arm.com, andreyknvl@gmail.com, ardb@kernel.org, masahiroy@kernel.org, kaleshsingh@google.com, madvenka@linux.microsoft.com, mhiramat@kernel.org, maz@kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.19 03/58] arm64: kasan: do not instrument stacktrace.c Date: Sun, 7 Aug 2022 21:30:21 -0400 Message-Id: <20220808013118.313965-3-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220808013118.313965-1-sashal@kernel.org> References: <20220808013118.313965-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220807_183134_774290_5722F8B0 X-CRM114-Status: GOOD ( 15.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Konovalov [ Upstream commit 802b91118d11227b527153849ea761b280691373 ] Disable KASAN instrumentation of arch/arm64/kernel/stacktrace.c. This speeds up Generic KASAN by 5-20%. As a side-effect, KASAN is now unable to detect bugs in the stack trace collection code. This is taken as an acceptable downside. Also replace READ_ONCE_NOCHECK() with READ_ONCE() in stacktrace.c. As the file is now not instrumented, there is no need to use the NOCHECK version of READ_ONCE(). Suggested-by: Mark Rutland Acked-by: Mark Rutland Signed-off-by: Andrey Konovalov Link: https://lore.kernel.org/r/c4c944a2a905e949760fbeb29258185087171708.1653317461.git.andreyknvl@google.com Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- arch/arm64/kernel/Makefile | 5 +++++ arch/arm64/kernel/stacktrace.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index fa7981d0d917..7075a9c6a4a6 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -14,6 +14,11 @@ CFLAGS_REMOVE_return_address.o = $(CC_FLAGS_FTRACE) CFLAGS_REMOVE_syscall.o = -fstack-protector -fstack-protector-strong CFLAGS_syscall.o += -fno-stack-protector +# When KASAN is enabled, a stack trace is recorded for every alloc/free, which +# can significantly impact performance. Avoid instrumenting the stack trace +# collection code to minimize this impact. +KASAN_SANITIZE_stacktrace.o := n + # It's not safe to invoke KCOV when portions of the kernel environment aren't # available or are out-of-sync with HW state. Since `noinstr` doesn't always # inhibit KCOV instrumentation, disable it for the entire compilation unit. diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index 0467cb79f080..c246e8d9f95b 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -124,8 +124,8 @@ static int notrace unwind_next(struct task_struct *tsk, * Record this frame record's values and location. The prev_fp and * prev_type are only meaningful to the next unwind_next() invocation. */ - state->fp = READ_ONCE_NOCHECK(*(unsigned long *)(fp)); - state->pc = READ_ONCE_NOCHECK(*(unsigned long *)(fp + 8)); + state->fp = READ_ONCE(*(unsigned long *)(fp)); + state->pc = READ_ONCE(*(unsigned long *)(fp + 8)); state->prev_fp = fp; state->prev_type = info.type; -- 2.35.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel