Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3295196lfo; Mon, 23 May 2022 00:58:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCzXBzOcqmL0kaJ9ScZSCwc0mYorD7B8oAgvprhGS0Xttni1k6BU+xTmZiQw5VJPUXv/Ea X-Received: by 2002:a17:902:c752:b0:161:7cb4:78b8 with SMTP id q18-20020a170902c75200b001617cb478b8mr21443890plq.39.1653292692915; Mon, 23 May 2022 00:58:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653292692; cv=none; d=google.com; s=arc-20160816; b=T6yj1Mtu8biyTpEQZRTWUM8e3x4SSNZWZJQNRxGlBQfdcDXWXlLOo+F+XqOMrKA4xk alADztV1Nvy/BAHy2fNtaDzA2mUx7zyF/xvkBhZGi/S25XjFCZ1oxSKrsFTSmh9AdpyQ P4M2tqNrosAfbRpEcOckH5bJwOGsD/LBHbgn9y5TuZkGNQP23rHh7peOyFTnumosrNOB ZAVWwaCgrc4HvO8ihiHy6/rQjlFVHxJUarvhZc7DbX911N9JMG4Y26XEFInQnXPTcFcR 6njtEGCLs0oPopskKoL1EQV82Z9+RkwPzVkp3wcINvTcbgNVZ7bfMEjURFc/18BDoinJ kaRQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=Vy7Ak3F0cMwR4NDgJNAiMt1tqQVmnBF5Rj3rg221j68=; b=pdbrqvBXvlsZpcQkMS+zwwohAXmYMwAuWhKoeU91QM95FMtmgUseq9cU/jwA5FR6B4 pk0yy1wEcqPR4/qFLKYKme7gYzTFTCzmKolCNjTTGuTBzByH15ubbmGCLFh80cYmbbcx cCxo8a5l/7bOywIje+NbEwjZrjBwrPqrvrq2GMzltmE6zug0wGxnKSuP2BeqWMVbnXiE Xn8zJmh0Nr49WWlH09VKW1ng8nDKKEuBYACDcNNp462fvRGX68p+000DQOxCgYDoJuZ6 xLWgXpPUYywzHmmldUcQ/XtwIFesckOXMk3n9uE0hNSn4X5Y1B8YXaqOozT5xHVCRrKX kdZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=SUmBT+dy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id a193-20020a6390ca000000b003ab45d6e89dsi9731189pge.218.2022.05.23.00.58.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 00:58:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=SUmBT+dy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8E887230209; Mon, 23 May 2022 00:00:23 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347392AbiEUXvK (ORCPT + 99 others); Sat, 21 May 2022 19:51:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245043AbiEUXvI (ORCPT ); Sat, 21 May 2022 19:51:08 -0400 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DD16220D9 for ; Sat, 21 May 2022 16:51:03 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1653177061; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Vy7Ak3F0cMwR4NDgJNAiMt1tqQVmnBF5Rj3rg221j68=; b=SUmBT+dywr8KVt4aoiuH2M3+BxG79p6/AO1BHjmyp9Un+owxWRFHH1r+jjFD07QDZp6Z0j 5Cgb6h2LszIWU2sHQnDBMbeccu1hbK+JpIeZ/ako3tvtCp9uEDQD4uueS0RUNAYZf3aBb2 SrE3U+96Fl+XOnRjt/Q86NqfLZVkmGY= From: andrey.konovalov@linux.dev To: Mark Rutland Cc: Andrey Konovalov , Marco Elver , Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Catalin Marinas , Vincenzo Frascino , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH 1/2] arm64: kasan: do not instrument stacktrace.c Date: Sun, 22 May 2022 01:50:58 +0200 Message-Id: <697e015e22ea78b021c2546f390ad5d773f3af86.1653177005.git.andreyknvl@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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 Signed-off-by: Andrey Konovalov --- arch/arm64/kernel/Makefile | 3 +++ arch/arm64/kernel/stacktrace.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index fa7981d0d917..da8cf6905c76 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -14,6 +14,9 @@ CFLAGS_REMOVE_return_address.o = $(CC_FLAGS_FTRACE) CFLAGS_REMOVE_syscall.o = -fstack-protector -fstack-protector-strong CFLAGS_syscall.o += -fno-stack-protector +# Do not instrument to improve performance. +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 e4103e085681..33e96ae4b15f 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -110,8 +110,8 @@ static int notrace unwind_frame(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_frame() invocation. */ - frame->fp = READ_ONCE_NOCHECK(*(unsigned long *)(fp)); - frame->pc = READ_ONCE_NOCHECK(*(unsigned long *)(fp + 8)); + frame->fp = READ_ONCE(*(unsigned long *)(fp)); + frame->pc = READ_ONCE(*(unsigned long *)(fp + 8)); frame->prev_fp = fp; frame->prev_type = info.type; -- 2.25.1