From patchwork Tue Sep 7 14:13:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Elver X-Patchwork-Id: 12478823 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.3 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, 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 BCC56C433F5 for ; Tue, 7 Sep 2021 14:14:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7014C61101 for ; Tue, 7 Sep 2021 14:14:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7014C61101 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 1271394000A; Tue, 7 Sep 2021 10:14:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D763940007; Tue, 7 Sep 2021 10:14:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE17794000A; Tue, 7 Sep 2021 10:14:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0243.hostedemail.com [216.40.44.243]) by kanga.kvack.org (Postfix) with ESMTP id DCB2A940007 for ; Tue, 7 Sep 2021 10:14:12 -0400 (EDT) Received: from smtpin32.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8D9A38249980 for ; Tue, 7 Sep 2021 14:14:12 +0000 (UTC) X-FDA: 78560971944.32.C7AAED6 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) by imf26.hostedemail.com (Postfix) with ESMTP id 3D54A20019ED for ; Tue, 7 Sep 2021 14:14:12 +0000 (UTC) Received: by mail-wr1-f74.google.com with SMTP id j1-20020adff541000000b001593715d384so2158462wrp.1 for ; Tue, 07 Sep 2021 07:14:12 -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=+Rc+8EwMgZeFDUhTR7EsEOP4LhinEf5yz1jFhEz7Lys=; b=C+fu87GoZkKgIPoEvuCyV89//ZnQ2k/l0TxbqWn0XEyAUEP7eZBz2sQEtKAoLtfAPo i4LUEghiCtacFi/u4ZPEyOr9w+StX0mLitUoVCMJrqQv26+ON3iTipxat+SJB8Z4OWpj Rjz/abmjaqw+fhtK2VgNo5/xLy2Bj8tBR17vDoq2moBJSp0TqEYKtCs4bEiiPYdPpcNa zmBkQP95QLt2XqYlZbVycFi+CRCBDXubJIy0o7OrzSw6+xm+W9cElegagvtA2UzKNxCV R72bRGrU0M/WoCET7xXJt4z286/MhTPWFbyAS4LNDW1YWWBcJfHejyx1DKCTIoVzuCZo 4Pyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=+Rc+8EwMgZeFDUhTR7EsEOP4LhinEf5yz1jFhEz7Lys=; b=PWNDU49DxCE25qmK9cm7uzsKyIp+eCuLfuf1Nvm4bQKfz9tS8MDHtYM0xGg54Gb1vk P1yr0TNR7dwB/wXlfWV8LBfnozSqR0qIT6OtLoN/6p8Dp0vpL+x4UCvaZ1UvmeQwC451 cP5mjh6SOgpEogdzeByl/+wPjMIoBxVeoJg8kYp88ABli7z3C8tLKFbhxd29B53A2fer U741+GfxVimtrqNBd6upKkv8RrfXYgMDxi8aGVSnT0KEwNkcK8mW29oDOebUGj/etYQ+ u9lWDCA+uvWdQKmLCxgK9IyIts5a3jhPh4o6jqaVk5tszW57uYYqK4eO/wKb0M9uI3w7 pzvg== X-Gm-Message-State: AOAM530eZupe9GEC97QibKag1AC+6hhCYGxOlVBQYJ0zSJA5fl5kh73e Y2QtdclqGcLCmbZR7pezXNy1An4Q5g== X-Google-Smtp-Source: ABdhPJy5j8OSOmcWadIfuPxP8jPndBqUduiq6MfhVDnHUz5ko0W2/iEvw7OfLAojWDgpFpRc1AZPp+GF2w== X-Received: from elver.muc.corp.google.com ([2a00:79e0:15:13:6800:c1ea:4271:5898]) (user=elver job=sendgmr) by 2002:a05:600c:4106:: with SMTP id j6mr4288917wmi.102.1631024050593; Tue, 07 Sep 2021 07:14:10 -0700 (PDT) Date: Tue, 7 Sep 2021 16:13:05 +0200 In-Reply-To: <20210907141307.1437816-1-elver@google.com> Message-Id: <20210907141307.1437816-5-elver@google.com> Mime-Version: 1.0 References: <20210907141307.1437816-1-elver@google.com> X-Mailer: git-send-email 2.33.0.153.gba50c8fa24-goog Subject: [PATCH 4/6] kasan: common: provide can_alloc in kasan_save_stack() From: Marco Elver To: elver@google.com Cc: Andrew Morton , Shuah Khan , Tejun Heo , Lai Jiangshan , Andrey Konovalov , Walter Wu , 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-Queue-Id: 3D54A20019ED Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=C+fu87Go; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf26.hostedemail.com: domain of 3snM3YQUKCIcpw6p2rzzrwp.nzxwty58-xxv6lnv.z2r@flex--elver.bounces.google.com designates 209.85.221.74 as permitted sender) smtp.mailfrom=3snM3YQUKCIcpw6p2rzzrwp.nzxwty58-xxv6lnv.z2r@flex--elver.bounces.google.com X-Rspamd-Server: rspam01 X-Stat-Signature: ou5bargsrb3u3ddyx7g3f8s4ar5kdb7h X-HE-Tag: 1631024052-839117 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: 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 --- 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 fa02c88b6948..e442d94a8f6e 100644 --- a/mm/kasan/kasan.h +++ b/mm/kasan/kasan.h @@ -260,7 +260,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,