mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
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: 5d4c6ac946
("kasan: record and report more information")
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: Juntong Deng <juntong.deng@outlook.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
f6940e8adc
commit
04afc540e5
@ -293,13 +293,8 @@ struct kasan_free_meta {
|
||||
struct kasan_stack_ring_entry {
|
||||
void *ptr;
|
||||
size_t size;
|
||||
u32 pid;
|
||||
depot_stack_handle_t stack;
|
||||
struct kasan_track track;
|
||||
bool is_free;
|
||||
#ifdef CONFIG_KASAN_EXTRA_INFO
|
||||
u64 cpu:20;
|
||||
u64 timestamp:44;
|
||||
#endif /* CONFIG_KASAN_EXTRA_INFO */
|
||||
};
|
||||
|
||||
struct kasan_stack_ring {
|
||||
|
@ -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,
|
||||
struct kasan_stack_ring_entry *entry)
|
||||
{
|
||||
track->cpu = entry->cpu;
|
||||
track->timestamp = entry->timestamp;
|
||||
track->cpu = entry->track.cpu;
|
||||
track->timestamp = entry->track.timestamp;
|
||||
}
|
||||
#endif /* CONFIG_KASAN_EXTRA_INFO */
|
||||
|
||||
@ -80,8 +80,8 @@ void kasan_complete_mode_report_info(struct kasan_report_info *info)
|
||||
if (free_found)
|
||||
break;
|
||||
|
||||
info->free_track.pid = entry->pid;
|
||||
info->free_track.stack = entry->stack;
|
||||
info->free_track.pid = entry->track.pid;
|
||||
info->free_track.stack = entry->track.stack;
|
||||
#ifdef CONFIG_KASAN_EXTRA_INFO
|
||||
kasan_complete_extra_report_info(&info->free_track, entry);
|
||||
#endif /* CONFIG_KASAN_EXTRA_INFO */
|
||||
@ -98,8 +98,8 @@ void kasan_complete_mode_report_info(struct kasan_report_info *info)
|
||||
if (alloc_found)
|
||||
break;
|
||||
|
||||
info->alloc_track.pid = entry->pid;
|
||||
info->alloc_track.stack = entry->stack;
|
||||
info->alloc_track.pid = entry->track.pid;
|
||||
info->alloc_track.stack = entry->track.stack;
|
||||
#ifdef CONFIG_KASAN_EXTRA_INFO
|
||||
kasan_complete_extra_report_info(&info->alloc_track, entry);
|
||||
#endif /* CONFIG_KASAN_EXTRA_INFO */
|
||||
|
@ -100,8 +100,8 @@ static void save_extra_info(struct kasan_stack_ring_entry *entry)
|
||||
u32 cpu = raw_smp_processor_id();
|
||||
u64 ts_nsec = local_clock();
|
||||
|
||||
entry->cpu = cpu;
|
||||
entry->timestamp = ts_nsec >> 3;
|
||||
entry->track.cpu = cpu;
|
||||
entry->track.timestamp = ts_nsec >> 3;
|
||||
}
|
||||
#endif /* CONFIG_KASAN_EXTRA_INFO */
|
||||
|
||||
@ -134,15 +134,15 @@ next:
|
||||
if (!try_cmpxchg(&entry->ptr, &old_ptr, STACK_RING_BUSY_PTR))
|
||||
goto next; /* Busy slot. */
|
||||
|
||||
old_stack = entry->stack;
|
||||
old_stack = entry->track.stack;
|
||||
|
||||
entry->size = cache->object_size;
|
||||
entry->pid = current->pid;
|
||||
entry->stack = stack;
|
||||
entry->is_free = is_free;
|
||||
entry->track.pid = current->pid;
|
||||
entry->track.stack = stack;
|
||||
#ifdef CONFIG_KASAN_EXTRA_INFO
|
||||
save_extra_info(entry);
|
||||
#endif /* CONFIG_KASAN_EXTRA_INFO */
|
||||
entry->is_free = is_free;
|
||||
|
||||
entry->ptr = object;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user