summaryrefslogtreecommitdiff
path: root/mm/kasan
diff options
context:
space:
mode:
authorAndrey Konovalov <andreyknvl@google.com>2023-12-21 19:35:38 +0100
committerAndrew Morton <akpm@linux-foundation.org>2023-12-29 11:58:46 -0800
commit04afc540e58e8f66fd85b0b88af3e8ce286be17c (patch)
tree8a6fe1d3ac34ac7d7f851fa22d2cf94aa1822350 /mm/kasan
parentf6940e8adc64f584dcfb2960f6e4b6a54ea9c508 (diff)
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: 5d4c6ac94694 ("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>
Diffstat (limited to 'mm/kasan')
-rw-r--r--mm/kasan/kasan.h7
-rw-r--r--mm/kasan/report_tags.c12
-rw-r--r--mm/kasan/tags.c12
3 files changed, 13 insertions, 18 deletions
diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h
index acc1a9410f0d..a280bb04c0e6 100644
--- a/mm/kasan/kasan.h
+++ b/mm/kasan/kasan.h
@@ -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 {
diff --git a/mm/kasan/report_tags.c b/mm/kasan/report_tags.c
index 979f284c2497..688b9d70b04a 100644
--- a/mm/kasan/report_tags.c
+++ b/mm/kasan/report_tags.c
@@ -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 */
diff --git a/mm/kasan/tags.c b/mm/kasan/tags.c
index c13b198b8302..c4d14dbf27c0 100644
--- a/mm/kasan/tags.c
+++ b/mm/kasan/tags.c
@@ -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;