All of lore.kernel.org
 help / color / mirror / Atom feed
From: andrey.konovalov@linux.dev
To: Marco Elver <elver@google.com>, Alexander Potapenko <glider@google.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>,
	Dmitry Vyukov <dvyukov@google.com>,
	Andrey Ryabinin <ryabinin.a.a@gmail.com>,
	kasan-dev@googlegroups.com,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Andrey Konovalov <andreyknvl@google.com>
Subject: [PATCH mm 20/22] kasan: reorder reporting functions
Date: Wed,  2 Mar 2022 17:36:40 +0100	[thread overview]
Message-ID: <82aa926c411e00e76e97e645a551ede9ed0c5e79.1646237226.git.andreyknvl@google.com> (raw)
In-Reply-To: <cover.1646237226.git.andreyknvl@google.com>

From: Andrey Konovalov <andreyknvl@google.com>

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 <andreyknvl@google.com>
---
 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


  parent reply	other threads:[~2022-03-02 16:40 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-02 16:36 [PATCH mm 00/22] kasan: report clean-ups and improvements andrey.konovalov
2022-03-02 16:36 ` [PATCH mm 01/22] kasan: drop addr check from describe_object_addr andrey.konovalov
2022-03-02 17:27   ` Alexander Potapenko
2022-03-02 16:36 ` [PATCH mm 02/22] kasan: more line breaks in reports andrey.konovalov
2022-03-02 17:28   ` Alexander Potapenko
2022-03-02 16:36 ` [PATCH mm 03/22] kasan: rearrange stack frame info " andrey.konovalov
2022-03-02 17:29   ` Alexander Potapenko
2022-03-02 16:36 ` [PATCH mm 04/22] kasan: improve " andrey.konovalov
2022-03-02 17:31   ` Alexander Potapenko
2022-03-02 16:36 ` [PATCH mm 05/22] kasan: print basic stack frame info for SW_TAGS andrey.konovalov
2022-03-02 17:34   ` Alexander Potapenko
2022-03-08 14:09     ` Andrey Konovalov
2022-03-02 16:36 ` [PATCH mm 06/22] kasan: simplify async check in end_report andrey.konovalov
2022-03-02 17:37   ` Alexander Potapenko
2022-03-08 14:09     ` Andrey Konovalov
2022-03-02 16:36 ` [PATCH mm 07/22] kasan: simplify kasan_update_kunit_status and call sites andrey.konovalov
2022-03-02 17:46   ` Alexander Potapenko
2022-03-02 16:36 ` [PATCH mm 08/22] kasan: check CONFIG_KASAN_KUNIT_TEST instead of CONFIG_KUNIT andrey.konovalov
2022-03-02 17:57   ` Alexander Potapenko
2022-03-02 16:36 ` [PATCH mm 09/22] kasan: move update_kunit_status to start_report andrey.konovalov
2022-03-02 16:36 ` [PATCH mm 10/22] kasan: move disable_trace_on_warning " andrey.konovalov
2022-03-02 18:00   ` Alexander Potapenko
2022-03-02 16:36 ` [PATCH mm 11/22] kasan: split out print_report from __kasan_report andrey.konovalov
2022-03-02 16:36 ` [PATCH mm 12/22] kasan: simplify kasan_find_first_bad_addr call sites andrey.konovalov
2022-03-02 16:36 ` [PATCH mm 13/22] kasan: restructure kasan_report andrey.konovalov
2022-03-02 16:36 ` [PATCH mm 14/22] kasan: merge __kasan_report into kasan_report andrey.konovalov
2022-03-02 16:36 ` [PATCH mm 15/22] kasan: call print_report from kasan_report_invalid_free andrey.konovalov
2022-03-02 16:36 ` [PATCH mm 16/22] kasan: move and simplify kasan_report_async andrey.konovalov
2022-03-02 16:36 ` [PATCH mm 17/22] kasan: rename kasan_access_info to kasan_report_info andrey.konovalov
2022-03-02 16:36 ` [PATCH mm 18/22] kasan: add comment about UACCESS regions to kasan_report andrey.konovalov
2022-03-02 16:36 ` [PATCH mm 19/22] kasan: respect KASAN_BIT_REPORTED in all reporting routines andrey.konovalov
2022-03-02 16:36 ` andrey.konovalov [this message]
2022-03-02 16:36 ` [PATCH mm 21/22] kasan: move and hide kasan_save_enable/restore_multi_shot andrey.konovalov
2022-03-02 16:36 ` [PATCH mm 22/22] kasan: disable LOCKDEP when printing reports andrey.konovalov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=82aa926c411e00e76e97e645a551ede9ed0c5e79.1646237226.git.andreyknvl@google.com \
    --to=andrey.konovalov@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=andreyknvl@gmail.com \
    --cc=andreyknvl@google.com \
    --cc=dvyukov@google.com \
    --cc=elver@google.com \
    --cc=glider@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ryabinin.a.a@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.