Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp259026pxm; Wed, 2 Mar 2022 14:48:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJz/TWTxKycm73qX7GfrgRjwCMiV0LicZzJRpynqZ7Etnvb26ghfGdyHCe3BmXD0LJCJWw+I X-Received: by 2002:a05:6a00:1593:b0:4f6:6c38:f75d with SMTP id u19-20020a056a00159300b004f66c38f75dmr781085pfk.81.1646261321966; Wed, 02 Mar 2022 14:48:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646261321; cv=none; d=google.com; s=arc-20160816; b=1Fs3P+GR1mMtk7qsEmNhkWWpZ7fmIuT8VzXiVhyqefQOqjrOBHm3DVsrr5JSfEAehh bmMTIgJzNHRCs1DM3Wny9UmLAqHso8cDQ4vF+jY1cQhTZbIaSMqQDG0OTJPcP9odUOXL Cosm+yg4FEuo4TZBrEQQ137qqLnCfeC08/WYEbmYO9sb7fPS1e5rGJLeZV7Kb9bN6aaF fs6/zzlqJn230uBMW4G5ABEdFO6rt1gxt47KExWAEbYbHrWDHFFE3W38xe/RogPzo7td IBOrqqXKlHUoqlBn/aj/5I8K5oXzXMz58zzVm0hiRFEBHWsqJYHxQ2JbviU3CtdeD6vo y8Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=djMH4j9HV8SXlCfl9Af/XXd5VDpDAiry7CNPlQpwESU=; b=DUrbi7LmnASMLXJYIOebYe/py3HwyxCK9nYZjAJvtvFrDjt+tmuBcg0oebZQoZazU+ yMJJvutdHOYcHoaTrjndmLy4nlyOkS4MonF0EDpa8rIM+NlYgakkz8mP/p6araPCsuMI aBILYOnFGak24uDTkrFzEoyU7ajPCNUIkY1lySXYE3mZY6N3qKSQedX3gGfG6eAKSBfc thmjugqDiZ84XNJ8WtHc28gpYsY8Sk8InSzLlmVefFC9pmHCBxYWl/JX424aalejTIj2 VaRittlPQVydsuWsLmn6bCL9l6G0+py2ePVaFjtdPesb7CWNq2YZ7NyBg99UAxE6X2yb GjOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="PnZ2t/AN"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id t2-20020a17090a950200b001b8b4ebe253si6343435pjo.151.2022.03.02.14.48.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 14:48:41 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="PnZ2t/AN"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BB857FDFB9; Wed, 2 Mar 2022 14:40:14 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243514AbiCBQlA (ORCPT + 99 others); Wed, 2 Mar 2022 11:41:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243177AbiCBQkt (ORCPT ); Wed, 2 Mar 2022 11:40:49 -0500 Received: from out0.migadu.com (out0.migadu.com [IPv6:2001:41d0:2:267::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDD4CCF38A for ; Wed, 2 Mar 2022 08:40:03 -0800 (PST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1646239202; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=djMH4j9HV8SXlCfl9Af/XXd5VDpDAiry7CNPlQpwESU=; b=PnZ2t/ANIdtINzZYFaDix7C8GIFWc+Tcr3lo2iGiNpriUbTepgZwinlIDD+IUj0vIZXPAT PUWWJBTw6hHckQ1Q+E98GyyjPVqju9Ydl66WDlbG/CQjQkd9tMJr4XtT5MULXn29AcSCz2 GJxDfbMqH3fNp2GkTIiuEGRW74+fR8I= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko Cc: Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH mm 20/22] kasan: reorder reporting functions Date: Wed, 2 Mar 2022 17:36:40 +0100 Message-Id: <82aa926c411e00e76e97e645a551ede9ed0c5e79.1646237226.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrey Konovalov 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. Signed-off-by: Andrey Konovalov --- mm/kasan/report.c | 82 +++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/mm/kasan/report.c b/mm/kasan/report.c index ef649f5cee29..7ef3b0455603 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -84,24 +84,29 @@ static int __init kasan_set_multi_shot(char *str) } __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 *flags, void *addr) 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 void *addr) } } -/* - * 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; -- 2.25.1