kasan: drop CONFIG_KASAN_TAGS_IDENTIFY
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. Link: https://lkml.kernel.org/r/4c66ba98eb237e9ed9312c19d423bbcf4ecf88f8.1662411799.git.andreyknvl@google.com Signed-off-by: Andrey Konovalov <andreyknvl@google.com> Reviewed-by: Marco Elver <elver@google.com> Cc: Alexander Potapenko <glider@google.com> Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Evgenii Stepanov <eugenis@google.com> Cc: Peter Collingbourne <pcc@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
ccf643e6da
commit
687c85afa6
|
@ -167,14 +167,6 @@ config KASAN_STACK
|
||||||
as well, as it adds inline-style instrumentation that is run
|
as well, as it adds inline-style instrumentation that is run
|
||||||
unconditionally.
|
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
|
config KASAN_VMALLOC
|
||||||
bool "Check accesses to vmalloc allocations"
|
bool "Check accesses to vmalloc allocations"
|
||||||
depends on HAVE_ARCH_KASAN_VMALLOC
|
depends on HAVE_ARCH_KASAN_VMALLOC
|
||||||
|
|
|
@ -169,23 +169,13 @@ struct kasan_track {
|
||||||
depot_stack_handle_t stack;
|
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_alloc_meta {
|
||||||
struct kasan_track alloc_track;
|
struct kasan_track alloc_track;
|
||||||
/* Generic mode stores free track in kasan_free_meta. */
|
/* Generic mode stores free track in kasan_free_meta. */
|
||||||
#ifdef CONFIG_KASAN_GENERIC
|
#ifdef CONFIG_KASAN_GENERIC
|
||||||
depot_stack_handle_t aux_stack[2];
|
depot_stack_handle_t aux_stack[2];
|
||||||
#else
|
#else
|
||||||
struct kasan_track free_track[KASAN_NR_FREE_STACKS];
|
struct kasan_track free_track;
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_KASAN_TAGS_IDENTIFY
|
|
||||||
u8 free_pointer_tag[KASAN_NR_FREE_STACKS];
|
|
||||||
u8 free_track_idx;
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -5,37 +5,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "kasan.h"
|
#include "kasan.h"
|
||||||
#include "../slab.h"
|
|
||||||
|
|
||||||
const char *kasan_get_bug_type(struct kasan_report_info *info)
|
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
|
* If access_size is a negative number, then it has reason to be
|
||||||
* defined as out-of-bounds bug type.
|
* defined as out-of-bounds bug type.
|
||||||
|
|
|
@ -30,39 +30,22 @@ void kasan_save_free_info(struct kmem_cache *cache,
|
||||||
void *object, u8 tag)
|
void *object, u8 tag)
|
||||||
{
|
{
|
||||||
struct kasan_alloc_meta *alloc_meta;
|
struct kasan_alloc_meta *alloc_meta;
|
||||||
u8 idx = 0;
|
|
||||||
|
|
||||||
alloc_meta = kasan_get_alloc_meta(cache, object);
|
alloc_meta = kasan_get_alloc_meta(cache, object);
|
||||||
if (!alloc_meta)
|
if (!alloc_meta)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef CONFIG_KASAN_TAGS_IDENTIFY
|
kasan_set_track(&alloc_meta->free_track, GFP_NOWAIT);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct kasan_track *kasan_get_free_track(struct kmem_cache *cache,
|
struct kasan_track *kasan_get_free_track(struct kmem_cache *cache,
|
||||||
void *object, u8 tag)
|
void *object, u8 tag)
|
||||||
{
|
{
|
||||||
struct kasan_alloc_meta *alloc_meta;
|
struct kasan_alloc_meta *alloc_meta;
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
alloc_meta = kasan_get_alloc_meta(cache, object);
|
alloc_meta = kasan_get_alloc_meta(cache, object);
|
||||||
if (!alloc_meta)
|
if (!alloc_meta)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#ifdef CONFIG_KASAN_TAGS_IDENTIFY
|
return &alloc_meta->free_track;
|
||||||
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];
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue