Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3026393rwb; Mon, 15 Aug 2022 16:24:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR7P4Dl/0R8Y/Nqt/h25dSBzCIDP5t/CoJvulDx1yD6lvoJoDaJKJ+WKn7Vz+bI4pDe/1k+g X-Received: by 2002:a05:6402:1e8a:b0:43e:93ab:5ab8 with SMTP id f10-20020a0564021e8a00b0043e93ab5ab8mr16542155edf.211.1660605868991; Mon, 15 Aug 2022 16:24:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605868; cv=none; d=google.com; s=arc-20160816; b=ACOqmjEwZPJeX+gkHWIsaLFBom81gsOWDTFMbqdc736AuiD3dSr9coKgOI2XuJ1Npl LCWrMi1xsZurb2cPS/7pjA767I7gIye6HPBua1Xrb+z4FKexH7n8gSD4jqGdWvG4lqF/ XvtqvwprEE3jWUkFkr4yBYGaOaemJOm+nnxosaJrpTaagFNI59kUfaRj7hDJdq1WoOyN CSg9cE3tSxav/YAdT+3Op21z0DFNkKGIj9MUArJM49jvgrvu2tUolzUW5ze+CWxlO3oS Us2zP5YTA+1sTrUjFn5ali4Tab2V0GZyrSMk4vzzWcQSn9+YRCbSJ/0kHoqJRSgu2PCQ UiuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nz3mKXkkAicy9rM9DAyva4u4hR7P74J7v4x/Wagcvrg=; b=zzb/fIcMtggu+vc+sucdXdAzU14MxkUaBpNxUnUkeTJGBIQwO/IgTYXK/qf0i8OShP LNkd1dJEDL+65TnSYfh6x8LWhDIZfxRWs+MUmIIk2IVs+O0/piHgbKy7vD8hDoF1u5g5 Fiuhd/t63NcNnfqkrYSnu5H/7rgZbYTVZCGu0le9rt/+TQoP1wFMtq8m0VFKaW9tGYMu Z3muOOJllCwWo65ddbJIliZn1uGCl7D0oXlnNyoOYuVS0AKjQLuwuf+jkR4ItWnYQPKe ooCNiFCppBt89TnewLpbkrQ/UR5Q5o7Qmgfw4yKf/13MO3Z3GQin7SobY1J+87lqN6Gz gPiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lzwU+BRX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u26-20020a50951a000000b0044260de35ebsi7918673eda.214.2022.08.15.16.24.03; Mon, 15 Aug 2022 16:24:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lzwU+BRX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350884AbiHOWhR (ORCPT + 99 others); Mon, 15 Aug 2022 18:37:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348476AbiHOW2o (ORCPT ); Mon, 15 Aug 2022 18:28:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55B0FB6D7B; Mon, 15 Aug 2022 12:48:04 -0700 (PDT) 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 8F1016125E; Mon, 15 Aug 2022 19:48:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93BFBC433D6; Mon, 15 Aug 2022 19:48:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592883; bh=GUDAZS/+eUIcCGBBfhfW4KeWzTJXZXRYQZKOZTAGzHc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lzwU+BRXx7QH1UgkiltZMMinqINSt7AOXR+MpfJpGnmn47o12kB1BjNr+x0pepWmX aWpydLN9iA2wGeMrlo/3EMRdTkg5+MPm5DA8vM65kim1sOlxIwQoHy465a5B+FRsLa FuLkCV1GmO3yKhHtB+gYSYQktDYNMQD5hezkgURI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Rutland , Andrey Konovalov , Will Deacon , Sasha Levin Subject: [PATCH 5.19 0149/1157] arm64: kasan: do not instrument stacktrace.c Date: Mon, 15 Aug 2022 19:51:45 +0200 Message-Id: <20220815180445.630849382@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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