From patchwork Mon Feb 8 18:40:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 12076263 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=-16.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, 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 C2D9CC433DB for ; Mon, 8 Feb 2021 18:40:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3B0E064E6B for ; Mon, 8 Feb 2021 18:40:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B0E064E6B Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7C6646B0006; Mon, 8 Feb 2021 13:40:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 79C396B006C; Mon, 8 Feb 2021 13:40:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B1DD6B006E; Mon, 8 Feb 2021 13:40:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0107.hostedemail.com [216.40.44.107]) by kanga.kvack.org (Postfix) with ESMTP id 557256B0006 for ; Mon, 8 Feb 2021 13:40:42 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 1AE8D8152 for ; Mon, 8 Feb 2021 18:40:42 +0000 (UTC) X-FDA: 77795966724.28.turn13_4a10e9b27600 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id E89318146 for ; Mon, 8 Feb 2021 18:40:41 +0000 (UTC) X-HE-Tag: turn13_4a10e9b27600 X-Filterd-Recvd-Size: 5724 Received: from mail-qk1-f202.google.com (mail-qk1-f202.google.com [209.85.222.202]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Mon, 8 Feb 2021 18:40:41 +0000 (UTC) Received: by mail-qk1-f202.google.com with SMTP id u14so2133637qke.14 for ; Mon, 08 Feb 2021 10:40:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=H9qB3jddJUOiem40qnE4VNfE96DiVHMNVUIiz3DWDnA=; b=OSxYfK3dabPv8tJszQgtCOZqGIaOISBkbN3FDZhJ6HWrPpAOOVAQhHEY6THhas9pV/ F5A627x9q/0IJzaIDgwVPS035Gw88VxW8YyDmjkYuOG7r8KIaTvPzGNGsnCzo483hRVe t4gBMsqE+1ceWYYEioSzIHHmL7KpeVl+E6TNKPFeUl5ZyxzUs7v3LYt/NOKJ8IIV+gdv YH9DPbS546+/GdwOo2/8PBrzjPENUp2LA2L54+82eYdBEOILHNiIZ/gc1X4lr5u3DZ/F 4ErPQ451EuWbWegvetp3oUqWqxqf8U1mogspr4ZibqSaWZyV9V4TtB6mao1Pc1aBvcjd 34sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=H9qB3jddJUOiem40qnE4VNfE96DiVHMNVUIiz3DWDnA=; b=Kw+TzU0hsg27uvhhcU8gjEKNFrFojGsf7fJX9iymMeUTw4PbaHEM6momPH5eGKr/Kn DlwUgMA8A2SlfthfNmnX/7eTVgB0nUlprlEsJ9f2+WEVRB55j0huOSiTcYr3B1y3zzet CnaY+T9Iz9CFp7o3UnsvufeZ0AOPGdQCiPYbHLT/c1XgmeEHw5WYj4FlYaOwWOyd/+0K xuzFf7aCAImceDcKl0PJwNxJaVy0Es4VBW7jHjKBbEEG75OrpqEys52vJaoW+0bMZbxY tiTETHPVMrRcFrhlXkSK/XVMenePZf6dGMvxTzA4o5cCP9IqReF+i+lBMIoCnqMt/oBp KGbQ== X-Gm-Message-State: AOAM533vZgSmiemcgujz0rPzGEhA7HPgOyt6a7W4Hd8b9x9N5YnUm77p mhsj+bV6m48lhJ40hjieDtZlczs7wOD8hmVX X-Google-Smtp-Source: ABdhPJzSTUaCTxZYjBF058uNJK2c/itP+NEV/iFWV4Mxc/d/k+Ag8gL3Dm65t7OaKUMhS1Maikf9IX68CyO4ri5A X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:55a0:b27b:af1c:327]) (user=andreyknvl job=sendgmr) by 2002:a0c:c1cb:: with SMTP id v11mr13766499qvh.59.1612809640525; Mon, 08 Feb 2021 10:40:40 -0800 (PST) Date: Mon, 8 Feb 2021 19:40:36 +0100 Message-Id: <6678d77ceffb71f1cff2cf61560e2ffe7bb6bfe9.1612808820.git.andreyknvl@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.30.0.478.g8a0d178c01-goog Subject: [PATCH] kasan: fix stack traces dependency for HW_TAGS From: Andrey Konovalov To: Andrew Morton , Catalin Marinas , Vincenzo Frascino , Dmitry Vyukov , Alexander Potapenko , Marco Elver Cc: Will Deacon , Andrey Ryabinin , Peter Collingbourne , Evgenii Stepanov , Branislav Rankov , Kevin Brodsky , kasan-dev@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Currently, whether the alloc/free stack traces collection is enabled by default for hardware tag-based KASAN depends on CONFIG_DEBUG_KERNEL. The intention for this dependency was to only enable collection on slow debug kernels due to a significant perf and memory impact. As it turns out, CONFIG_DEBUG_KERNEL is not considered a debug option and is enabled on many productions kernels including Android and Ubuntu. As the result, this dependency is pointless and only complicates the code and documentation. Having stack traces collection disabled by default would make the hardware mode work differently to to the software ones, which is confusing. This change removes the dependency and enables stack traces collection by default. Looking into the future, this default might makes sense for production kernels, assuming we implement a fast stack trace collection approach. Signed-off-by: Andrey Konovalov Reviewed-by: Marco Elver --- Documentation/dev-tools/kasan.rst | 3 +-- mm/kasan/hw_tags.c | 8 ++------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/kasan.rst index 1651d961f06a..a248ac3941be 100644 --- a/Documentation/dev-tools/kasan.rst +++ b/Documentation/dev-tools/kasan.rst @@ -163,8 +163,7 @@ particular KASAN features. - ``kasan=off`` or ``=on`` controls whether KASAN is enabled (default: ``on``). - ``kasan.stacktrace=off`` or ``=on`` disables or enables alloc and free stack - traces collection (default: ``on`` for ``CONFIG_DEBUG_KERNEL=y``, otherwise - ``off``). + traces collection (default: ``on``). - ``kasan.fault=report`` or ``=panic`` controls whether to only print a KASAN report or also panic the kernel (default: ``report``). diff --git a/mm/kasan/hw_tags.c b/mm/kasan/hw_tags.c index e529428e7a11..d558799b25b3 100644 --- a/mm/kasan/hw_tags.c +++ b/mm/kasan/hw_tags.c @@ -134,12 +134,8 @@ void __init kasan_init_hw_tags(void) switch (kasan_arg_stacktrace) { case KASAN_ARG_STACKTRACE_DEFAULT: - /* - * Default to enabling stack trace collection for - * debug kernels. - */ - if (IS_ENABLED(CONFIG_DEBUG_KERNEL)) - static_branch_enable(&kasan_flag_stacktrace); + /* Default to enabling stack trace collection. */ + static_branch_enable(&kasan_flag_stacktrace); break; case KASAN_ARG_STACKTRACE_OFF: /* Do nothing, kasan_flag_stacktrace keeps its default value. */