Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1835970ioo; Mon, 23 May 2022 04:35:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkw9AAZPhXYkjBPRMwX7PPb2rXHxlqV1u5qIEiUNdXfistR5yPqhu6giVquHhYvlqwmUGh X-Received: by 2002:a65:6bc7:0:b0:3f5:fdf7:12e2 with SMTP id e7-20020a656bc7000000b003f5fdf712e2mr19507849pgw.13.1653305716486; Mon, 23 May 2022 04:35:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653305716; cv=none; d=google.com; s=arc-20160816; b=XeGol3mMa/hUQJUXJHoANwOg0i3TnTnsQ+H0ss1SX+5GtPuCLHm/HoLJydrM7jmP5i S4uwRjoE3JvjiWPpTa+UJ2vrKX5iEdBX0H/8XvaLE2K1lejkpGstN3QW0rpTAU0SLiWe tzBT8GfNMTMVrOBxJPI3va3kIDEIt4ScdYLQv4ZZ3ovCdowiLMcR9DJP2l1B7KvVKtvN JgOZuaXfMJwG+fYBeaugo58XuvTXXoByMuUd9p9LU6Ee4RYH0kRfvHZvqAtnmhPyXAwc y0WVLfGLm3UIZt6DWR2Ut8nK7knGxFd6b+UAqSwKn6nRCgPV3Z7On0xwAOTNqEaKa9cK FXuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=XNT5MdP6tzK2RfufBFU9iRlBFu2p3wIno2G6EVmT8Yw=; b=MaxbCImyLBChsgtmA+KG6RiefRJ/IbbyPaz8hALp/SlLsQHFgMSiU+fK1t0AUhpvp+ z1i9vJpLuLA67EDIIbAUlWUVddP9WuFu6wKisI7k7lfsHGMcYacMATH/dMdvaYx1hwZ1 WgKQDxmsLJR7gufzkWYNmpMDE7dVIDTYzS4DKTWtSC4kN0RBLKeKQi10v7H1n9pYbDKE bKZPFa/YpQgYXkfEf+tQCPj1IvLOT/YQcRGPsVdUQhtrO29fFHmCtl4x8pZzDVuntVtT FBws2CpaqHlJ9VOCA0k3gfMwAZIIRaaLEUggfaP723JusOAIY9iOCluh+91UyKvk7GfJ KaNw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id l13-20020a170903120d00b0015d0c53ae0esi13088256plh.491.2022.05.23.04.35.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 04:35:16 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7D53E5004D; Mon, 23 May 2022 04:35:01 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234963AbiEWLeD (ORCPT + 99 others); Mon, 23 May 2022 07:34:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234951AbiEWLd5 (ORCPT ); Mon, 23 May 2022 07:33:57 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6EBE24F9EE for ; Mon, 23 May 2022 04:33:55 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2DA6311FB; Mon, 23 May 2022 04:33:55 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.9.63]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C661C3F73D; Mon, 23 May 2022 04:33:52 -0700 (PDT) Date: Mon, 23 May 2022 12:33:48 +0100 From: Mark Rutland To: andrey.konovalov@linux.dev 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: Re: [PATCH 1/2] arm64: kasan: do not instrument stacktrace.c Message-ID: References: <697e015e22ea78b021c2546f390ad5d773f3af86.1653177005.git.andreyknvl@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <697e015e22ea78b021c2546f390ad5d773f3af86.1653177005.git.andreyknvl@google.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, 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 On Sun, May 22, 2022 at 01:50:58AM +0200, andrey.konovalov@linux.dev wrote: > 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 Can we make that a little more descriptive? e.g. # When KASAN is enabled, a stacktrace is recorded for every alloc/free, which # can significantly impact performance. Avoid instrumenting the stacktrace code # to minimize this impact. KASAN_SANITIZE_stacktrace.o := n With that: Acked-by: Mark Rutland Mark. > + > # 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 >