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: 12076267 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=-17.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 33566C433E0 for ; Mon, 8 Feb 2021 18:42:03 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CB6E764E6B for ; Mon, 8 Feb 2021 18:42:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB6E764E6B Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:Subject:Mime-Version:Message-Id:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=Xu3/2T5EQJim5/eL/Xn96cKO9pJOqYYpEjqkMq2RdCI=; b=fQKcHXWAKxhn1ZHaefa2MwwJ5H C58B1vvVO7PAzVJI08M45p0A9nw77NoBNp9b2ugEqhP9IkilH2yy65/jI5e047fE4Tk7PQGzoSdhj 6h81+WrkYstNnQgM7XFpn01h2U/JA8a/mYLKIfQDa2G8+YumbWCZkyEVvCBes+4ff4B1bnD71xvh9 24DgToy+4mVC0K/yLgyCdJQ4Yrxq57iFbHnC34Vg/qUE+hFXZDLFMLf9MZ7+DaHuHvTsMBOQ8bjIY 9dn9dTXL81LQMnD4/C77VxLEEI9UAi7SHv5jWcbM+gVos0+v2+v6lkhneKAySpbKD6OUNmxqtB36l Vs4Nq67w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l9BSo-0007TY-Kw; Mon, 08 Feb 2021 18:40:46 +0000 Received: from mail-qv1-xf4a.google.com ([2607:f8b0:4864:20::f4a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l9BSm-0007Rq-Ke for linux-arm-kernel@lists.infradead.org; Mon, 08 Feb 2021 18:40:45 +0000 Received: by mail-qv1-xf4a.google.com with SMTP id n1so11244470qvi.4 for ; Mon, 08 Feb 2021 10:40:42 -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=QacdMx1K32ySIm50/U66ZEkfGhBE/WZsjpd62c+uEI+z9EcbSDLwnPAmHr+Go1XcSo GAWuVfwdinfV7/ipS6jZtY6e+kh0Bjt59DdFOHV7Ei6NvSWTgKZnufeAtCgB9/RE7mow Eq8mFWh3MgA6oT9vc9oDazYbph3eC1jCfV8g+/8O1TpM5ixORA5lJ/IB6O2kvEROqikl ahll85+b1AD7sKpaK/NsI/Vfr7M+hBvemvDCkSpjZqRXLMsUE+JBUF1jjFVms2tGspUV uQEztMVFZ5a1vMHrIQOS+Cd2YvvvG2kw14ZeBE6ATaUVdLm9NEo8svYpog57Lpk/0u+t UavA== X-Gm-Message-State: AOAM532M1a9lQknTEMGPBRsqNcA/m6+A8vTpnWcQMkI0yVGxxRNZ35nb 7ok1FWu9tbo1J5BNeyYyECX++aS87cmtH6Hm 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210208_134044_693948_92BD9C54 X-CRM114-Status: GOOD ( 16.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Branislav Rankov , Andrey Konovalov , Kevin Brodsky , Will Deacon , linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, Andrey Ryabinin , Peter Collingbourne , Evgenii Stepanov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. */