Skip to content

Commit

Permalink
kasan: check object_size in kasan_complete_mode_report_info
Browse files Browse the repository at this point in the history
Check the object size when looking up entries in the stack ring.

If the size of the object for which a report is being printed does not
match the size of the object for which a stack trace has been saved in the
stack ring, the saved stack trace is irrelevant.

Link: https://lkml.kernel.org/r/68c6948175aadd7e7e7deea61725103d64a4528f.1700502145.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Reviewed-by: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Evgenii Stepanov <eugenis@google.com>
Cc: Marco Elver <elver@google.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
Andrey Konovalov authored and Andrew Morton committed Dec 11, 2023
1 parent f3b5979 commit 7d88e4f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mm/kasan/report_tags.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <linux/atomic.h>

#include "kasan.h"
#include "../slab.h"

extern struct kasan_stack_ring stack_ring;

Expand Down Expand Up @@ -58,7 +59,8 @@ void kasan_complete_mode_report_info(struct kasan_report_info *info)
entry = &stack_ring.entries[i % stack_ring.size];

if (kasan_reset_tag(entry->ptr) != info->object ||
get_tag(entry->ptr) != get_tag(info->access_addr))
get_tag(entry->ptr) != get_tag(info->access_addr) ||
info->cache->object_size != entry->size)
continue;

if (entry->is_free) {
Expand Down

0 comments on commit 7d88e4f

Please sign in to comment.