Commit 04afc540 authored by Andrey Konovalov's avatar Andrey Konovalov Committed by Andrew Morton

kasan: reuse kasan_track in kasan_stack_ring_entry

Avoid duplicating fields of kasan_track in kasan_stack_ring_entry: reuse
the structure.

Link: https://lkml.kernel.org/r/20231221183540.168428-2-andrey.konovalov@linux.dev
Fixes: 5d4c6ac9 ("kasan: record and report more information")
Signed-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
Reviewed-by: default avatarMarco 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: Juntong Deng <juntong.deng@outlook.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent f6940e8a
...@@ -293,13 +293,8 @@ struct kasan_free_meta { ...@@ -293,13 +293,8 @@ struct kasan_free_meta {
struct kasan_stack_ring_entry { struct kasan_stack_ring_entry {
void *ptr; void *ptr;
size_t size; size_t size;
u32 pid; struct kasan_track track;
depot_stack_handle_t stack;
bool is_free; bool is_free;
#ifdef CONFIG_KASAN_EXTRA_INFO
u64 cpu:20;
u64 timestamp:44;
#endif /* CONFIG_KASAN_EXTRA_INFO */
}; };
struct kasan_stack_ring { struct kasan_stack_ring {
......
...@@ -31,8 +31,8 @@ static const char *get_common_bug_type(struct kasan_report_info *info) ...@@ -31,8 +31,8 @@ static const char *get_common_bug_type(struct kasan_report_info *info)
static void kasan_complete_extra_report_info(struct kasan_track *track, static void kasan_complete_extra_report_info(struct kasan_track *track,
struct kasan_stack_ring_entry *entry) struct kasan_stack_ring_entry *entry)
{ {
track->cpu = entry->cpu; track->cpu = entry->track.cpu;
track->timestamp = entry->timestamp; track->timestamp = entry->track.timestamp;
} }
#endif /* CONFIG_KASAN_EXTRA_INFO */ #endif /* CONFIG_KASAN_EXTRA_INFO */
...@@ -80,8 +80,8 @@ void kasan_complete_mode_report_info(struct kasan_report_info *info) ...@@ -80,8 +80,8 @@ void kasan_complete_mode_report_info(struct kasan_report_info *info)
if (free_found) if (free_found)
break; break;
info->free_track.pid = entry->pid; info->free_track.pid = entry->track.pid;
info->free_track.stack = entry->stack; info->free_track.stack = entry->track.stack;
#ifdef CONFIG_KASAN_EXTRA_INFO #ifdef CONFIG_KASAN_EXTRA_INFO
kasan_complete_extra_report_info(&info->free_track, entry); kasan_complete_extra_report_info(&info->free_track, entry);
#endif /* CONFIG_KASAN_EXTRA_INFO */ #endif /* CONFIG_KASAN_EXTRA_INFO */
...@@ -98,8 +98,8 @@ void kasan_complete_mode_report_info(struct kasan_report_info *info) ...@@ -98,8 +98,8 @@ void kasan_complete_mode_report_info(struct kasan_report_info *info)
if (alloc_found) if (alloc_found)
break; break;
info->alloc_track.pid = entry->pid; info->alloc_track.pid = entry->track.pid;
info->alloc_track.stack = entry->stack; info->alloc_track.stack = entry->track.stack;
#ifdef CONFIG_KASAN_EXTRA_INFO #ifdef CONFIG_KASAN_EXTRA_INFO
kasan_complete_extra_report_info(&info->alloc_track, entry); kasan_complete_extra_report_info(&info->alloc_track, entry);
#endif /* CONFIG_KASAN_EXTRA_INFO */ #endif /* CONFIG_KASAN_EXTRA_INFO */
......
...@@ -100,8 +100,8 @@ static void save_extra_info(struct kasan_stack_ring_entry *entry) ...@@ -100,8 +100,8 @@ static void save_extra_info(struct kasan_stack_ring_entry *entry)
u32 cpu = raw_smp_processor_id(); u32 cpu = raw_smp_processor_id();
u64 ts_nsec = local_clock(); u64 ts_nsec = local_clock();
entry->cpu = cpu; entry->track.cpu = cpu;
entry->timestamp = ts_nsec >> 3; entry->track.timestamp = ts_nsec >> 3;
} }
#endif /* CONFIG_KASAN_EXTRA_INFO */ #endif /* CONFIG_KASAN_EXTRA_INFO */
...@@ -134,15 +134,15 @@ static void save_stack_info(struct kmem_cache *cache, void *object, ...@@ -134,15 +134,15 @@ static void save_stack_info(struct kmem_cache *cache, void *object,
if (!try_cmpxchg(&entry->ptr, &old_ptr, STACK_RING_BUSY_PTR)) if (!try_cmpxchg(&entry->ptr, &old_ptr, STACK_RING_BUSY_PTR))
goto next; /* Busy slot. */ goto next; /* Busy slot. */
old_stack = entry->stack; old_stack = entry->track.stack;
entry->size = cache->object_size; entry->size = cache->object_size;
entry->pid = current->pid; entry->track.pid = current->pid;
entry->stack = stack; entry->track.stack = stack;
entry->is_free = is_free;
#ifdef CONFIG_KASAN_EXTRA_INFO #ifdef CONFIG_KASAN_EXTRA_INFO
save_extra_info(entry); save_extra_info(entry);
#endif /* CONFIG_KASAN_EXTRA_INFO */ #endif /* CONFIG_KASAN_EXTRA_INFO */
entry->is_free = is_free;
entry->ptr = object; entry->ptr = object;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment