From: Marco Elver <elver@google.com>
To: andrey.konovalov@linux.dev
Cc: Alexander Potapenko <glider@google.com>,
Andrey Konovalov <andreyknvl@gmail.com>,
Dmitry Vyukov <dvyukov@google.com>,
Andrey Ryabinin <ryabinin.a.a@gmail.com>,
kasan-dev@googlegroups.com, Peter Collingbourne <pcc@google.com>,
Evgenii Stepanov <eugenis@google.com>,
Florian Mayer <fmayer@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Andrey Konovalov <andreyknvl@google.com>
Subject: Re: [PATCH 05/32] kasan: drop CONFIG_KASAN_TAGS_IDENTIFY
Date: Mon, 20 Jun 2022 15:39:42 +0200 [thread overview]
Message-ID: <CANpmjNNKKUkxOnOQBf5EZ3kCMv_wqd0V74R5Rx8K1+MhbXmSJQ@mail.gmail.com> (raw)
In-Reply-To: <cfc1744f4a5eb6f50eddee53238af1a2fb4e8583.1655150842.git.andreyknvl@google.com>
On Mon, 13 Jun 2022 at 22:15, <andrey.konovalov@linux.dev> wrote:
>
> From: Andrey Konovalov <andreyknvl@google.com>
>
> Drop CONFIG_KASAN_TAGS_IDENTIFY and related code to simplify making
> changes to the reporting code.
>
> The dropped functionality will be restored in the following patches in
> this series.
>
> Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Reviewed-by: Marco Elver <elver@google.com>
> ---
> lib/Kconfig.kasan | 8 --------
> mm/kasan/kasan.h | 12 +-----------
> mm/kasan/report_tags.c | 28 ----------------------------
> mm/kasan/tags.c | 21 ++-------------------
> 4 files changed, 3 insertions(+), 66 deletions(-)
>
> diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan
> index f0973da583e0..ca09b1cf8ee9 100644
> --- a/lib/Kconfig.kasan
> +++ b/lib/Kconfig.kasan
> @@ -167,14 +167,6 @@ config KASAN_STACK
> as well, as it adds inline-style instrumentation that is run
> unconditionally.
>
> -config KASAN_TAGS_IDENTIFY
> - bool "Memory corruption type identification"
> - depends on KASAN_SW_TAGS || KASAN_HW_TAGS
> - help
> - Enables best-effort identification of the bug types (use-after-free
> - or out-of-bounds) at the cost of increased memory consumption.
> - Only applicable for the tag-based KASAN modes.
> -
> config KASAN_VMALLOC
> bool "Check accesses to vmalloc allocations"
> depends on HAVE_ARCH_KASAN_VMALLOC
> diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h
> index 610057e651d2..aa6b43936f8d 100644
> --- a/mm/kasan/kasan.h
> +++ b/mm/kasan/kasan.h
> @@ -168,23 +168,13 @@ struct kasan_track {
> depot_stack_handle_t stack;
> };
>
> -#if defined(CONFIG_KASAN_TAGS_IDENTIFY) && defined(CONFIG_KASAN_SW_TAGS)
> -#define KASAN_NR_FREE_STACKS 5
> -#else
> -#define KASAN_NR_FREE_STACKS 1
> -#endif
> -
> struct kasan_alloc_meta {
> struct kasan_track alloc_track;
> /* Generic mode stores free track in kasan_free_meta. */
> #ifdef CONFIG_KASAN_GENERIC
> depot_stack_handle_t aux_stack[2];
> #else
> - struct kasan_track free_track[KASAN_NR_FREE_STACKS];
> -#endif
> -#ifdef CONFIG_KASAN_TAGS_IDENTIFY
> - u8 free_pointer_tag[KASAN_NR_FREE_STACKS];
> - u8 free_track_idx;
> + struct kasan_track free_track;
> #endif
> };
>
> diff --git a/mm/kasan/report_tags.c b/mm/kasan/report_tags.c
> index e25d2166e813..35cf3cae4aa4 100644
> --- a/mm/kasan/report_tags.c
> +++ b/mm/kasan/report_tags.c
> @@ -5,37 +5,9 @@
> */
>
> #include "kasan.h"
> -#include "../slab.h"
>
> const char *kasan_get_bug_type(struct kasan_report_info *info)
> {
> -#ifdef CONFIG_KASAN_TAGS_IDENTIFY
> - struct kasan_alloc_meta *alloc_meta;
> - struct kmem_cache *cache;
> - struct slab *slab;
> - const void *addr;
> - void *object;
> - u8 tag;
> - int i;
> -
> - tag = get_tag(info->access_addr);
> - addr = kasan_reset_tag(info->access_addr);
> - slab = kasan_addr_to_slab(addr);
> - if (slab) {
> - cache = slab->slab_cache;
> - object = nearest_obj(cache, slab, (void *)addr);
> - alloc_meta = kasan_get_alloc_meta(cache, object);
> -
> - if (alloc_meta) {
> - for (i = 0; i < KASAN_NR_FREE_STACKS; i++) {
> - if (alloc_meta->free_pointer_tag[i] == tag)
> - return "use-after-free";
> - }
> - }
> - return "out-of-bounds";
> - }
> -#endif
> -
> /*
> * If access_size is a negative number, then it has reason to be
> * defined as out-of-bounds bug type.
> diff --git a/mm/kasan/tags.c b/mm/kasan/tags.c
> index 1ba3c8399f72..e0e5de8ce834 100644
> --- a/mm/kasan/tags.c
> +++ b/mm/kasan/tags.c
> @@ -30,39 +30,22 @@ void kasan_save_free_info(struct kmem_cache *cache,
> void *object, u8 tag)
> {
> struct kasan_alloc_meta *alloc_meta;
> - u8 idx = 0;
>
> alloc_meta = kasan_get_alloc_meta(cache, object);
> if (!alloc_meta)
> return;
>
> -#ifdef CONFIG_KASAN_TAGS_IDENTIFY
> - idx = alloc_meta->free_track_idx;
> - alloc_meta->free_pointer_tag[idx] = tag;
> - alloc_meta->free_track_idx = (idx + 1) % KASAN_NR_FREE_STACKS;
> -#endif
> -
> - kasan_set_track(&alloc_meta->free_track[idx], GFP_NOWAIT);
> + kasan_set_track(&alloc_meta->free_track, GFP_NOWAIT);
> }
>
> struct kasan_track *kasan_get_free_track(struct kmem_cache *cache,
> void *object, u8 tag)
> {
> struct kasan_alloc_meta *alloc_meta;
> - int i = 0;
>
> alloc_meta = kasan_get_alloc_meta(cache, object);
> if (!alloc_meta)
> return NULL;
>
> -#ifdef CONFIG_KASAN_TAGS_IDENTIFY
> - for (i = 0; i < KASAN_NR_FREE_STACKS; i++) {
> - if (alloc_meta->free_pointer_tag[i] == tag)
> - break;
> - }
> - if (i == KASAN_NR_FREE_STACKS)
> - i = alloc_meta->free_track_idx;
> -#endif
> -
> - return &alloc_meta->free_track[i];
> + return &alloc_meta->free_track;
> }
> --
> 2.25.1
>
> --
> You received this message because you are subscribed to the Google Groups "kasan-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to kasan-dev+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/cfc1744f4a5eb6f50eddee53238af1a2fb4e8583.1655150842.git.andreyknvl%40google.com.
next prev parent reply other threads:[~2022-06-20 13:40 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-13 20:13 [PATCH 00/32] kasan: switch tag-based modes to stack ring from per-object metadata andrey.konovalov
2022-06-13 20:13 ` [PATCH 01/32] kasan: check KASAN_NO_FREE_META in __kasan_metadata_size andrey.konovalov
2022-06-20 13:39 ` Marco Elver
2022-06-13 20:13 ` [PATCH 02/32] kasan: rename kasan_set_*_info to kasan_save_*_info andrey.konovalov
2022-06-20 13:39 ` Marco Elver
2022-06-13 20:13 ` [PATCH 03/32] kasan: move is_kmalloc check out of save_alloc_info andrey.konovalov
2022-06-20 13:39 ` Marco Elver
2022-06-13 20:13 ` [PATCH 04/32] kasan: split save_alloc_info implementations andrey.konovalov
2022-06-20 13:39 ` Marco Elver
2022-06-13 20:13 ` [PATCH 05/32] kasan: drop CONFIG_KASAN_TAGS_IDENTIFY andrey.konovalov
2022-06-20 13:39 ` Marco Elver [this message]
2022-06-13 20:13 ` [PATCH 06/32] kasan: introduce kasan_print_aux_stacks andrey.konovalov
2022-06-17 11:34 ` Marco Elver
2022-07-18 22:41 ` Andrey Konovalov
2022-06-13 20:13 ` [PATCH 07/32] kasan: introduce kasan_get_alloc_track andrey.konovalov
2022-06-20 13:39 ` Marco Elver
2022-06-13 20:13 ` [PATCH 08/32] kasan: introduce kasan_init_object_meta andrey.konovalov
2022-06-20 13:39 ` Marco Elver
2022-06-13 20:14 ` [PATCH 09/32] kasan: clear metadata functions for tag-based modes andrey.konovalov
2022-06-20 13:39 ` Marco Elver
2022-06-13 20:14 ` [PATCH 10/32] kasan: move kasan_get_*_meta to generic.c andrey.konovalov
2022-06-13 20:14 ` [PATCH 11/32] kasan: introduce kasan_requires_meta andrey.konovalov
2022-06-13 20:14 ` [PATCH 12/32] kasan: introduce kasan_init_cache_meta andrey.konovalov
2022-06-13 20:14 ` [PATCH 13/32] kasan: drop CONFIG_KASAN_GENERIC check from kasan_init_cache_meta andrey.konovalov
2022-06-13 20:14 ` [PATCH 14/32] kasan: only define kasan_metadata_size for Generic mode andrey.konovalov
2022-06-13 20:14 ` [PATCH 15/32] kasan: only define kasan_never_merge " andrey.konovalov
2022-06-13 20:14 ` [PATCH 16/32] kasan: only define metadata offsets " andrey.konovalov
2022-06-13 20:14 ` [PATCH 17/32] kasan: only define metadata structs " andrey.konovalov
2022-06-13 20:14 ` [PATCH 18/32] kasan: only define kasan_cache_create " andrey.konovalov
2022-06-13 20:14 ` [PATCH 19/32] kasan: pass tagged pointers to kasan_save_alloc/free_info andrey.konovalov
2022-06-20 9:54 ` Marco Elver
2022-07-18 22:41 ` Andrey Konovalov
2022-06-13 20:14 ` [PATCH 20/32] kasan: move kasan_get_alloc/free_track definitions andrey.konovalov
2022-06-13 20:14 ` [PATCH 21/32] kasan: simplify invalid-free reporting andrey.konovalov
2022-06-21 7:17 ` Kuan-Ying Lee
2022-07-12 20:38 ` Andrey Konovalov
2022-06-13 20:14 ` [PATCH 22/32] kasan: cosmetic changes in report.c andrey.konovalov
2022-06-13 20:14 ` [PATCH 23/32] kasan: use kasan_addr_to_slab in print_address_description andrey.konovalov
2022-06-13 20:14 ` [PATCH 24/32] kasan: move kasan_addr_to_slab to common.c andrey.konovalov
2022-06-15 13:27 ` kernel test robot
2022-07-18 22:41 ` Andrey Konovalov
2022-06-13 20:14 ` [PATCH 25/32] kasan: make kasan_addr_to_page static andrey.konovalov
2022-06-13 20:14 ` [PATCH 26/32] kasan: simplify print_report andrey.konovalov
2022-06-13 20:14 ` [PATCH 27/32] kasan: introduce complete_report_info andrey.konovalov
2022-06-13 20:14 ` [PATCH 28/32] kasan: fill in cache and object in complete_report_info andrey.konovalov
2022-06-13 20:14 ` [PATCH 29/32] kasan: rework function arguments in report.c andrey.konovalov
2022-06-13 20:14 ` [PATCH 30/32] kasan: introduce kasan_complete_mode_report_info andrey.konovalov
2022-06-13 20:14 ` [PATCH 31/32] kasan: implement stack ring for tag-based modes andrey.konovalov
2022-06-20 13:35 ` Marco Elver
2022-07-18 22:42 ` Andrey Konovalov
2022-06-13 20:14 ` [PATCH 32/32] kasan: better identify bug types " andrey.konovalov
2022-06-17 9:32 ` [PATCH 00/32] kasan: switch tag-based modes to stack ring from per-object metadata Marco Elver
2022-07-18 22:41 ` 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=CANpmjNNKKUkxOnOQBf5EZ3kCMv_wqd0V74R5Rx8K1+MhbXmSJQ@mail.gmail.com \
--to=elver@google.com \
--cc=akpm@linux-foundation.org \
--cc=andrey.konovalov@linux.dev \
--cc=andreyknvl@gmail.com \
--cc=andreyknvl@google.com \
--cc=dvyukov@google.com \
--cc=eugenis@google.com \
--cc=fmayer@google.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pcc@google.com \
--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