From patchwork Fri Mar 25 01:13:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12791192 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD3E4C433EF for ; Fri, 25 Mar 2022 01:13:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 55EDE8D0032; Thu, 24 Mar 2022 21:13:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 50D898D0005; Thu, 24 Mar 2022 21:13:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3613B8D0032; Thu, 24 Mar 2022 21:13:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 287858D0005 for ; Thu, 24 Mar 2022 21:13:14 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 02A8977F for ; Fri, 25 Mar 2022 01:13:14 +0000 (UTC) X-FDA: 79281135108.06.BC2335E Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf04.hostedemail.com (Postfix) with ESMTP id 1F3B94002F for ; Fri, 25 Mar 2022 01:13:12 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id A2068CE2812; Fri, 25 Mar 2022 01:13:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36AA8C340EC; Fri, 25 Mar 2022 01:13:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1648170790; bh=h4r6priBT5Kd6mSJOksQhJs4en29aa1lPfNSHb5RK00=; h=Date:To:From:In-Reply-To:Subject:From; b=F7BGOEfA4j1bJxJ4/nKVya8WEchvuO9YjL/YK8irdP/lr2c0ksYpN59HWacQm/Qqb fLPiHQMdc027JILu7ohhn2yIwdhJhsmta28p2mvRXyauRToJMO8VPXT2e1A2dXmoZ6 bIacgZjOfhSZuHAkH1SYXKwd5n7JrbbxPl08Oq8M= Date: Thu, 24 Mar 2022 18:13:09 -0700 To: ryabinin.a.a@gmail.com,glider@google.com,elver@google.com,dvyukov@google.com,andreyknvl@google.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220324180758.96b1ac7e17675d6bc474485e@linux-foundation.org> Subject: [patch 092/114] kasan: reorder reporting functions Message-Id: <20220325011310.36AA8C340EC@smtp.kernel.org> X-Stat-Signature: 46bomwqieoqhdcr1tk5wtteb63nbshkr Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=F7BGOEfA; spf=pass (imf04.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 1F3B94002F X-HE-Tag: 1648170792-169722 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: From: Andrey Konovalov Subject: kasan: reorder reporting functions Move print_error_description()'s, report_suppressed()'s, and report_enabled()'s definitions to improve the logical order of function definitions in report.c. No functional changes. Link: https://lkml.kernel.org/r/82aa926c411e00e76e97e645a551ede9ed0c5e79.1646237226.git.andreyknvl@google.com Signed-off-by: Andrey Konovalov Cc: Alexander Potapenko Cc: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Marco Elver Signed-off-by: Andrew Morton --- mm/kasan/report.c | 82 ++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 41 deletions(-) --- a/mm/kasan/report.c~kasan-reorder-reporting-functions +++ a/mm/kasan/report.c @@ -84,24 +84,29 @@ static int __init kasan_set_multi_shot(c } __setup("kasan_multi_shot", kasan_set_multi_shot); -static void print_error_description(struct kasan_report_info *info) +/* + * Used to suppress reports within kasan_disable/enable_current() critical + * sections, which are used for marking accesses to slab metadata. + */ +static bool report_suppressed(void) { - if (info->type == KASAN_REPORT_INVALID_FREE) { - pr_err("BUG: KASAN: double-free or invalid-free in %pS\n", - (void *)info->ip); - return; - } +#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS) + if (current->kasan_depth) + return true; +#endif + return false; +} - pr_err("BUG: KASAN: %s in %pS\n", - kasan_get_bug_type(info), (void *)info->ip); - if (info->access_size) - pr_err("%s of size %zu at addr %px by task %s/%d\n", - info->is_write ? "Write" : "Read", info->access_size, - info->access_addr, current->comm, task_pid_nr(current)); - else - pr_err("%s at addr %px by task %s/%d\n", - info->is_write ? "Write" : "Read", - info->access_addr, current->comm, task_pid_nr(current)); +/* + * Used to avoid reporting more than one KASAN bug unless kasan_multi_shot + * is enabled. Note that KASAN tests effectively enable kasan_multi_shot + * for their duration. + */ +static bool report_enabled(void) +{ + if (test_bit(KASAN_BIT_MULTI_SHOT, &kasan_flags)) + return true; + return !test_and_set_bit(KASAN_BIT_REPORTED, &kasan_flags); } #if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST) @@ -160,6 +165,26 @@ static void end_report(unsigned long *fl kasan_enable_current(); } +static void print_error_description(struct kasan_report_info *info) +{ + if (info->type == KASAN_REPORT_INVALID_FREE) { + pr_err("BUG: KASAN: double-free or invalid-free in %pS\n", + (void *)info->ip); + return; + } + + pr_err("BUG: KASAN: %s in %pS\n", + kasan_get_bug_type(info), (void *)info->ip); + if (info->access_size) + pr_err("%s of size %zu at addr %px by task %s/%d\n", + info->is_write ? "Write" : "Read", info->access_size, + info->access_addr, current->comm, task_pid_nr(current)); + else + pr_err("%s at addr %px by task %s/%d\n", + info->is_write ? "Write" : "Read", + info->access_addr, current->comm, task_pid_nr(current)); +} + static void print_track(struct kasan_track *track, const char *prefix) { pr_err("%s by task %u:\n", prefix, track->pid); @@ -381,31 +406,6 @@ static void print_memory_metadata(const } } -/* - * Used to suppress reports within kasan_disable/enable_current() critical - * sections, which are used for marking accesses to slab metadata. - */ -static bool report_suppressed(void) -{ -#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS) - if (current->kasan_depth) - return true; -#endif - return false; -} - -/* - * Used to avoid reporting more than one KASAN bug unless kasan_multi_shot - * is enabled. Note that KASAN tests effectively enable kasan_multi_shot - * for their duration. - */ -static bool report_enabled(void) -{ - if (test_bit(KASAN_BIT_MULTI_SHOT, &kasan_flags)) - return true; - return !test_and_set_bit(KASAN_BIT_REPORTED, &kasan_flags); -} - static void print_report(struct kasan_report_info *info) { void *tagged_addr = info->access_addr;