From: andrey.konovalov@linux.dev
To: Marco Elver <elver@google.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>,
Alexander Potapenko <glider@google.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 04/11] kasan: clean up kasan_requires_meta
Date: Thu, 21 Dec 2023 21:04:46 +0100 [thread overview]
Message-ID: <8086623407095ac1c82377a2107dcc5845f99cfa.1703188911.git.andreyknvl@google.com> (raw)
In-Reply-To: <cover.1703188911.git.andreyknvl@google.com>
From: Andrey Konovalov <andreyknvl@google.com>
Currently, for Generic KASAN mode, kasan_requires_meta is defined to
return kasan_stack_collection_enabled.
Even though the Generic mode does not support disabling stack trace
collection, kasan_requires_meta was implemented in this way to make it
easier to implement the disabling for the Generic mode in the future.
However, for the Generic mode, the per-object metadata also stores the
quarantine link. So even if disabling stack collection is implemented,
the per-object metadata will still be required.
Fix kasan_requires_meta to return true for the Generic mode and update
the related comments.
This change does not fix any observable bugs but rather just brings the
code to a cleaner state.
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
---
mm/kasan/kasan.h | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h
index 0e209b823b2c..38af25b9c89c 100644
--- a/mm/kasan/kasan.h
+++ b/mm/kasan/kasan.h
@@ -101,21 +101,21 @@ static inline bool kasan_sample_page_alloc(unsigned int order)
#ifdef CONFIG_KASAN_GENERIC
-/* Generic KASAN uses per-object metadata to store stack traces. */
+/*
+ * Generic KASAN uses per-object metadata to store alloc and free stack traces
+ * and the quarantine link.
+ */
static inline bool kasan_requires_meta(void)
{
- /*
- * Technically, Generic KASAN always collects stack traces right now.
- * However, let's use kasan_stack_collection_enabled() in case the
- * kasan.stacktrace command-line argument is changed to affect
- * Generic KASAN.
- */
- return kasan_stack_collection_enabled();
+ return true;
}
#else /* CONFIG_KASAN_GENERIC */
-/* Tag-based KASAN modes do not use per-object metadata. */
+/*
+ * Tag-based KASAN modes do not use per-object metadata: they use the stack
+ * ring to store alloc and free stack traces and do not use qurantine.
+ */
static inline bool kasan_requires_meta(void)
{
return false;
--
2.25.1
next prev parent reply other threads:[~2023-12-21 20:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-21 20:04 [PATCH mm 00/11] kasan: assorted clean-ups andrey.konovalov
2023-12-21 20:04 ` [PATCH mm 01/11] kasan/arm64: improve comments for KASAN_SHADOW_START/END andrey.konovalov
2023-12-21 20:04 ` [PATCH mm 02/11] mm, kasan: use KASAN_TAG_KERNEL instead of 0xff andrey.konovalov
2023-12-21 20:04 ` [PATCH mm 03/11] kasan: improve kasan_non_canonical_hook andrey.konovalov
2023-12-21 20:04 ` andrey.konovalov [this message]
2023-12-21 20:04 ` [PATCH mm 05/11] kasan: update kasan_poison documentation comment andrey.konovalov
2023-12-21 20:04 ` [PATCH mm 06/11] kasan: clean up is_kfence_address checks andrey.konovalov
2023-12-21 20:04 ` [PATCH mm 07/11] kasan: respect CONFIG_KASAN_VMALLOC for kasan_flag_vmalloc andrey.konovalov
2023-12-21 20:04 ` [PATCH mm 08/11] kasan: check kasan_vmalloc_enabled in vmalloc tests andrey.konovalov
2023-12-21 20:04 ` [PATCH mm 09/11] kasan: export kasan_poison as GPL andrey.konovalov
2023-12-21 20:04 ` [PATCH mm 10/11] kasan: remove SLUB checks for page_alloc fallbacks in tests andrey.konovalov
2023-12-21 20:04 ` [PATCH mm 11/11] kasan: speed up match_all_mem_tag test for SW_TAGS 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=8086623407095ac1c82377a2107dcc5845f99cfa.1703188911.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox