From patchwork Fri Nov 22 11:25:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11257865 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 41EDA1871 for ; Fri, 22 Nov 2019 11:26:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 01BF620708 for ; Fri, 22 Nov 2019 11:26:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Onx+/KTV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 01BF620708 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 D4A416B04C6; Fri, 22 Nov 2019 06:26:37 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CF7CB6B04C7; Fri, 22 Nov 2019 06:26:37 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B98B16B04C8; Fri, 22 Nov 2019 06:26:37 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0018.hostedemail.com [216.40.44.18]) by kanga.kvack.org (Postfix) with ESMTP id 9D96F6B04C6 for ; Fri, 22 Nov 2019 06:26:37 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 6583F4DD9 for ; Fri, 22 Nov 2019 11:26:37 +0000 (UTC) X-FDA: 76183685634.11.desk55_910c40fb1db63 X-Spam-Summary: 2,0,0,0041095a6dfcb08d,d41d8cd98f00b204,368xxxqykcmow1ytu7w44w1u.s421y3ad-220bqs0.47w@flex--glider.bounces.google.com,:vegard.nossum@oracle.com:dvyukov@google.com:aryabinin@virtuozzo.com::glider@google.com:viro@zeniv.linux.org.uk:adilger.kernel@dilger.ca:akpm@linux-foundation.org:andreyknvl@google.com:luto@kernel.org:ard.biesheuvel@linaro.org:arnd@arndb.de:hch@infradead.org:hch@lst.de:darrick.wong@oracle.com:davem@davemloft.net:dmitry.torokhov@gmail.com:ebiggers@google.com:edumazet@google.com:ericvh@gmail.com:gregkh@linuxfoundation.org:harry.wentland@amd.com:herbert@gondor.apana.org.au:iii@linux.ibm.com:mingo@elte.hu:jasowang@redhat.com:axboe@kernel.dk:m.szyprowski@samsung.com:elver@google.com:mark.rutland@arm.com:martin.petersen@oracle.com:schwidefsky@de.ibm.com:willy@infradead.org:mst@redhat.com:monstr@monstr.eu:pmladek@suse.com:cai@lca.pw:rdunlap@infradead.org:robin.murphy@arm.com:sergey.senozhatsky@gmail.com:rostedt@goodmis.org:tiwai@suse.com:tytso@mit.edu :tglx@li X-HE-Tag: desk55_910c40fb1db63 X-Filterd-Recvd-Size: 6939 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Fri, 22 Nov 2019 11:26:36 +0000 (UTC) Received: by mail-wm1-f73.google.com with SMTP id 199so3306339wmb.0 for ; Fri, 22 Nov 2019 03:26:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=KDaH9axn++VMEUnsyuxRE1Rff8Tw9RQbRacoxaG6c/Y=; b=Onx+/KTVLz6h3ZB5wBqaCCuFI915L2xLpNndgIaW5q++YE26GSYefnPRRfCns7zl/0 WPGn8Gi3WAFM5rubpjvEkKiY0gH30IlAnbIA4s7wV2R1mIK65Obts13B2NdEbaPy6C4k lCXbb7H/sErPUrrBMjkHfKMErN1LfVLJm0/7vViK65ZT2GXl6BvBiO4W01ldW1znL7sI VlnLcdb/vS2GfhWENCpocBYP9+3wUGUdjf2WdAP1Gn538LU9deDvk+zhoafHWBwXwCrN EksMiW57I8Og8Wizyy7BVHX7PoA5bxt7FjEhWEyd3aI3lU2Nzyh8J50PKIBDE0uNfwfr OR0g== 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=KDaH9axn++VMEUnsyuxRE1Rff8Tw9RQbRacoxaG6c/Y=; b=WlU3TIBwW2tWTn3B41+qsxLJuSeDDd4yn8vYBuO0AoLUPxieJlb0SGUxx+oMIhAOso SsRf8RG/aHToCHjgirVn/uAcgbPHWkkirm2m0gZGYIqXhBHGA6hXDmbf3WN+CcYZ+qan +cj0ZytATm0cRMTQhGi3up7MLuQq5d/Bmnvf5uo2+E2GHKDitdZ+yzS2oCTEqso/eGkg iAF+bs2SjhoXjKZlMeat2KJ9K9q9ib2jMb6k2Gy0u+XTMozgW8c9XeKCdnH+SffYgPVv R8hJgOeg3eMIp2FgNiRVwFb4690j2B0wD3cmKi/ZKY5p7sb4AJiu1xBlbNC1mzu0NcBC pGgQ== X-Gm-Message-State: APjAAAXkN5V9o9dWo3niqIB+PrNuO8vUYzmxOwZQAXABjPxQYLwJWE4X ZZRD7MQKocWNcc6vjui1w+N5IR0cWf4= X-Google-Smtp-Source: APXvYqwSFJeWpmI/HKW7rblGft42yZ/Xmgp6fvxAGyJsFLeoXcVNv+I2R8hZxmSntcowXxmTEMthTalP6Pk= X-Received: by 2002:a05:6000:104c:: with SMTP id c12mr16175681wrx.212.1574421995098; Fri, 22 Nov 2019 03:26:35 -0800 (PST) Date: Fri, 22 Nov 2019 12:25:48 +0100 In-Reply-To: <20191122112621.204798-1-glider@google.com> Message-Id: <20191122112621.204798-4-glider@google.com> Mime-Version: 1.0 References: <20191122112621.204798-1-glider@google.com> X-Mailer: git-send-email 2.24.0.432.g9d3f5f5b63-goog Subject: [PATCH RFC v3 03/36] kasan: stackdepot: move filter_irq_stacks() to stackdepot.c From: glider@google.com To: Vegard Nossum , Dmitry Vyukov , Andrey Ryabinin , linux-mm@kvack.org Cc: glider@google.com, viro@zeniv.linux.org.uk, adilger.kernel@dilger.ca, akpm@linux-foundation.org, andreyknvl@google.com, luto@kernel.org, ard.biesheuvel@linaro.org, arnd@arndb.de, hch@infradead.org, hch@lst.de, darrick.wong@oracle.com, davem@davemloft.net, dmitry.torokhov@gmail.com, ebiggers@google.com, edumazet@google.com, ericvh@gmail.com, gregkh@linuxfoundation.org, harry.wentland@amd.com, herbert@gondor.apana.org.au, iii@linux.ibm.com, mingo@elte.hu, jasowang@redhat.com, axboe@kernel.dk, m.szyprowski@samsung.com, elver@google.com, mark.rutland@arm.com, martin.petersen@oracle.com, schwidefsky@de.ibm.com, willy@infradead.org, mst@redhat.com, monstr@monstr.eu, pmladek@suse.com, cai@lca.pw, rdunlap@infradead.org, robin.murphy@arm.com, sergey.senozhatsky@gmail.com, rostedt@goodmis.org, tiwai@suse.com, tytso@mit.edu, tglx@linutronix.de, gor@linux.ibm.com, wsa@the-dreams.de 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: filter_irq_stacks() can be used by other tools (e.g. KMSAN), so it needs to be moved to a common location. lib/stackdepot.c seems a good place, as filter_irq_stacks() is usually applied to the output of stack_trace_save(). Signed-off-by: Alexander Potapenko To: Alexander Potapenko Cc: Vegard Nossum Cc: Dmitry Vyukov Cc: Andrey Ryabinin Cc: linux-mm@kvack.org --- Change-Id: I65acecf64930a3658e8c2aa7423801082ded8602 --- include/linux/stackdepot.h | 2 ++ lib/stackdepot.c | 23 +++++++++++++++++++++++ mm/kasan/common.c | 23 ----------------------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/include/linux/stackdepot.h b/include/linux/stackdepot.h index 3efa97d482cb..24d49c732341 100644 --- a/include/linux/stackdepot.h +++ b/include/linux/stackdepot.h @@ -19,4 +19,6 @@ depot_stack_handle_t stack_depot_save(unsigned long *entries, unsigned int stack_depot_fetch(depot_stack_handle_t handle, unsigned long **entries); +unsigned int filter_irq_stacks(unsigned long *entries, unsigned int nr_entries); + #endif diff --git a/lib/stackdepot.c b/lib/stackdepot.c index 6d1123123e56..eb95197b8743 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -20,6 +20,7 @@ */ #include +#include #include #include #include @@ -314,3 +315,25 @@ depot_stack_handle_t stack_depot_save(unsigned long *entries, return retval; } EXPORT_SYMBOL_GPL(stack_depot_save); + +static inline int in_irqentry_text(unsigned long ptr) +{ + return (ptr >= (unsigned long)&__irqentry_text_start && + ptr < (unsigned long)&__irqentry_text_end) || + (ptr >= (unsigned long)&__softirqentry_text_start && + ptr < (unsigned long)&__softirqentry_text_end); +} + +unsigned int filter_irq_stacks(unsigned long *entries, + unsigned int nr_entries) +{ + unsigned int i; + + for (i = 0; i < nr_entries; i++) { + if (in_irqentry_text(entries[i])) { + /* Include the irqentry function into the stack. */ + return i + 1; + } + } + return nr_entries; +} diff --git a/mm/kasan/common.c b/mm/kasan/common.c index 6814d6d6a023..154eba5700d8 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -15,7 +15,6 @@ */ #include -#include #include #include #include @@ -39,28 +38,6 @@ #include "kasan.h" #include "../slab.h" -static inline int in_irqentry_text(unsigned long ptr) -{ - return (ptr >= (unsigned long)&__irqentry_text_start && - ptr < (unsigned long)&__irqentry_text_end) || - (ptr >= (unsigned long)&__softirqentry_text_start && - ptr < (unsigned long)&__softirqentry_text_end); -} - -static inline unsigned int filter_irq_stacks(unsigned long *entries, - unsigned int nr_entries) -{ - unsigned int i; - - for (i = 0; i < nr_entries; i++) { - if (in_irqentry_text(entries[i])) { - /* Include the irqentry function into the stack. */ - return i + 1; - } - } - return nr_entries; -} - static inline depot_stack_handle_t save_stack(gfp_t flags) { unsigned long entries[KASAN_STACK_DEPTH];