From patchwork Mon Sep 13 11:26:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Elver X-Patchwork-Id: 12488581 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=-26.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 EB55DC433FE for ; Mon, 13 Sep 2021 11:26:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9E42760F44 for ; Mon, 13 Sep 2021 11:26:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9E42760F44 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 438EC6B0075; Mon, 13 Sep 2021 07:26:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3E8D76B0078; Mon, 13 Sep 2021 07:26:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 288A16B007B; Mon, 13 Sep 2021 07:26:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0217.hostedemail.com [216.40.44.217]) by kanga.kvack.org (Postfix) with ESMTP id 1B3EC6B0075 for ; Mon, 13 Sep 2021 07:26:38 -0400 (EDT) Received: from smtpin40.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id D4D428249980 for ; Mon, 13 Sep 2021 11:26:37 +0000 (UTC) X-FDA: 78582322434.40.4738860 Received: from mail-qv1-f73.google.com (mail-qv1-f73.google.com [209.85.219.73]) by imf16.hostedemail.com (Postfix) with ESMTP id 9B239F000091 for ; Mon, 13 Sep 2021 11:26:37 +0000 (UTC) Received: by mail-qv1-f73.google.com with SMTP id h9-20020a05621413a900b0037a2d3eaf8fso55845748qvz.8 for ; Mon, 13 Sep 2021 04:26:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ptSP4yyc5ltqSERpcwLdEP2vwQAqnRLUENIn1iThCXw=; b=lQJHcNeX6xmyAzHEBQijP50dslqB4ng/uZaXNlPMDkefvXL1DmklWKmkgYFNycLqh6 QqZ10XQ247wUWTQ2+uMyHvCrbximNAhp396NL4rInA4JSL8Y1fxCDV2JelnMx0Ndarrq 1iB+NB6DcgsFstDQpdu787ZRUaVXbr6bQJ8y60pGHOGar1RbB+jBt9vBN2OrR4Zmg2SC D3khYK6nF+5Wbzrq9be7/M/x9nXkcbXtPyOeanOwJ4M5+aHD4kQ2McxcB55ee7N396Ed 4/wIsAvhPXKTYR/JvOWtXQkyQi7jh+z85TBd7hBgH3lONGOFlRRPiZ2/BetPVsWzDX/v GH9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ptSP4yyc5ltqSERpcwLdEP2vwQAqnRLUENIn1iThCXw=; b=HDgkdEEuN7LFrJAYvTpziAoqDoPerytbewNaPQXNdAFTGgaUuY3jojVp4J40x97Lop tthBiOwY9ksd2MgGBCrDF2qlVEGQf37weSkz8HvuBqYYmIsEhBQ6rWlHDThNcEso+SPl FCugJwYzZBDdeRxZMEVNlMymTiUjRRA4Is2WV8ED6JJ/cYFqarXQGF2jMK3HTyiP1vP7 pPURYwSe8o0lHgX5cm+blxKZzi8/gwKLtV2P/J2e1SpFDMI+0EnxDFhgTVFwqusPyaSc sKlQpqPc5XDmShMwc70moxpF9abcqTx3EpATO9j+9wyzeSv10EfaTO5NJ5+MxyYg5Q6W 1jSQ== X-Gm-Message-State: AOAM5327AGkY9uTPzFhh0FaT+KQ9vpDKWfqsZsn0iqollEh7ImLtYYRI 3PL3d8mYj7ic/kAs5a/cUeuGx2GYeA== X-Google-Smtp-Source: ABdhPJwEq/LT0qtGFvFgCGkRgy6m1M7iEma80J+GQ4oANgWzfE9nbLt7djdJjIebizDl8HvmEU3Ms3Ha7Q== X-Received: from elver.muc.corp.google.com ([2a00:79e0:15:13:1f19:d46:38c8:7e48]) (user=elver job=sendgmr) by 2002:a05:6214:1142:: with SMTP id b2mr10077845qvt.0.1631532396945; Mon, 13 Sep 2021 04:26:36 -0700 (PDT) Date: Mon, 13 Sep 2021 13:26:07 +0200 In-Reply-To: <20210913112609.2651084-1-elver@google.com> Message-Id: <20210913112609.2651084-5-elver@google.com> Mime-Version: 1.0 References: <20210913112609.2651084-1-elver@google.com> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog Subject: [PATCH v2 4/6] kasan: common: provide can_alloc in kasan_save_stack() From: Marco Elver To: elver@google.com, Andrew Morton Cc: Shuah Khan , Tejun Heo , Lai Jiangshan , Andrey Konovalov , Walter Wu , Sebastian Andrzej Siewior , Thomas Gleixner , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Vijayanand Jitta , Vinayak Menon , "Gustavo A. R. Silva" , kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Aleksandr Nogikh , Taras Madan X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 9B239F000091 Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=lQJHcNeX; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf16.hostedemail.com: domain of 3bDU_YQUKCOMJQaJWLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--elver.bounces.google.com designates 209.85.219.73 as permitted sender) smtp.mailfrom=3bDU_YQUKCOMJQaJWLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--elver.bounces.google.com X-Stat-Signature: si1xzyq7cj9ogss1ah6yft6ddjwrbpo6 X-HE-Tag: 1631532397-332524 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Add another argument, can_alloc, to kasan_save_stack() which is passed as-is to __stack_depot_save(). No functional change intended. Signed-off-by: Marco Elver Tested-by: Shuah Khan Acked-by: Sebastian Andrzej Siewior --- mm/kasan/common.c | 6 +++--- mm/kasan/generic.c | 2 +- mm/kasan/kasan.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/kasan/common.c b/mm/kasan/common.c index 2baf121fb8c5..3e0999892c36 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -30,20 +30,20 @@ #include "kasan.h" #include "../slab.h" -depot_stack_handle_t kasan_save_stack(gfp_t flags) +depot_stack_handle_t kasan_save_stack(gfp_t flags, bool can_alloc) { unsigned long entries[KASAN_STACK_DEPTH]; unsigned int nr_entries; nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 0); nr_entries = filter_irq_stacks(entries, nr_entries); - return stack_depot_save(entries, nr_entries, flags); + return __stack_depot_save(entries, nr_entries, flags, can_alloc); } void kasan_set_track(struct kasan_track *track, gfp_t flags) { track->pid = current->pid; - track->stack = kasan_save_stack(flags); + track->stack = kasan_save_stack(flags, true); } #if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS) diff --git a/mm/kasan/generic.c b/mm/kasan/generic.c index c3f5ba7a294a..2a8e59e6326d 100644 --- a/mm/kasan/generic.c +++ b/mm/kasan/generic.c @@ -345,7 +345,7 @@ void kasan_record_aux_stack(void *addr) return; alloc_meta->aux_stack[1] = alloc_meta->aux_stack[0]; - alloc_meta->aux_stack[0] = kasan_save_stack(GFP_NOWAIT); + alloc_meta->aux_stack[0] = kasan_save_stack(GFP_NOWAIT, true); } void kasan_set_free_info(struct kmem_cache *cache, diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h index 8bf568a80eb8..fa6b48d08513 100644 --- a/mm/kasan/kasan.h +++ b/mm/kasan/kasan.h @@ -251,7 +251,7 @@ void kasan_report_invalid_free(void *object, unsigned long ip); struct page *kasan_addr_to_page(const void *addr); -depot_stack_handle_t kasan_save_stack(gfp_t flags); +depot_stack_handle_t kasan_save_stack(gfp_t flags, bool can_alloc); void kasan_set_track(struct kasan_track *track, gfp_t flags); void kasan_set_free_info(struct kmem_cache *cache, void *object, u8 tag); struct kasan_track *kasan_get_free_track(struct kmem_cache *cache,