mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
UPSTREAM: kasan: rework function arguments in report.c
Pass a pointer to kasan_report_info to describe_object() and
describe_object_stacks(), instead of passing the structure's fields.
The untagged pointer and the tag are still passed as separate arguments to
some of the functions to avoid duplicating the untagging logic.
This is preparatory change for the next patch.
Link: https://lkml.kernel.org/r/2e0cdb91524ab528a3c2b12b6d8bcb69512fc4af.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>
Bug: 254721825
(cherry picked from commit 92a38eacd6)
Change-Id: I0586c596aa5bd4e144618cfbebe750b6c3aeae2d
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
This commit is contained in:
@@ -209,8 +209,8 @@ struct page *kasan_addr_to_page(const void *addr)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void describe_object_addr(struct kmem_cache *cache, void *object,
|
||||
const void *addr)
|
||||
static void describe_object_addr(const void *addr, struct kmem_cache *cache,
|
||||
void *object)
|
||||
{
|
||||
unsigned long access_addr = (unsigned long)addr;
|
||||
unsigned long object_addr = (unsigned long)object;
|
||||
@@ -238,33 +238,32 @@ static void describe_object_addr(struct kmem_cache *cache, void *object,
|
||||
(void *)(object_addr + cache->object_size));
|
||||
}
|
||||
|
||||
static void describe_object_stacks(struct kmem_cache *cache, void *object,
|
||||
const void *addr, u8 tag)
|
||||
static void describe_object_stacks(u8 tag, struct kasan_report_info *info)
|
||||
{
|
||||
struct kasan_track *alloc_track;
|
||||
struct kasan_track *free_track;
|
||||
|
||||
alloc_track = kasan_get_alloc_track(cache, object);
|
||||
alloc_track = kasan_get_alloc_track(info->cache, info->object);
|
||||
if (alloc_track) {
|
||||
print_track(alloc_track, "Allocated");
|
||||
pr_err("\n");
|
||||
}
|
||||
|
||||
free_track = kasan_get_free_track(cache, object, tag);
|
||||
free_track = kasan_get_free_track(info->cache, info->object, tag);
|
||||
if (free_track) {
|
||||
print_track(free_track, "Freed");
|
||||
pr_err("\n");
|
||||
}
|
||||
|
||||
kasan_print_aux_stacks(cache, object);
|
||||
kasan_print_aux_stacks(info->cache, info->object);
|
||||
}
|
||||
|
||||
static void describe_object(struct kmem_cache *cache, void *object,
|
||||
const void *addr, u8 tag)
|
||||
static void describe_object(const void *addr, u8 tag,
|
||||
struct kasan_report_info *info)
|
||||
{
|
||||
if (kasan_stack_collection_enabled())
|
||||
describe_object_stacks(cache, object, addr, tag);
|
||||
describe_object_addr(cache, object, addr);
|
||||
describe_object_stacks(tag, info);
|
||||
describe_object_addr(addr, info->cache, info->object);
|
||||
}
|
||||
|
||||
static inline bool kernel_or_module_addr(const void *addr)
|
||||
@@ -292,7 +291,7 @@ static void print_address_description(void *addr, u8 tag,
|
||||
pr_err("\n");
|
||||
|
||||
if (info->cache && info->object) {
|
||||
describe_object(info->cache, info->object, addr, tag);
|
||||
describe_object(addr, tag, info);
|
||||
pr_err("\n");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user