kasan: add memory corruption identification for software tag-based mode
Add memory corruption identification at bug report for software tag-based mode. The report shows whether it is "use-after-free" or "out-of-bound" error instead of "invalid-access" error. This will make it easier for programmers to see the memory corruption problem. We extend the slab to store five old free pointer tag and free backtrace, we can check if the tagged address is in the slab record and make a good guess if the object is more like "use-after-free" or "out-of-bound". therefore every slab memory corruption can be identified whether it's "use-after-free" or "out-of-bound". [aryabinin@virtuozzo.com: simplify & clenup code] Link: https://lkml.kernel.org/r/3318f9d7-a760-3cc8-b700-f06108ae745f@virtuozzo.com] Link: http://lkml.kernel.org/r/20190821180332.11450-1-aryabinin@virtuozzo.com Signed-off-by: Walter Wu <walter-zh.wu@mediatek.com> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com> Acked-by: Andrey Konovalov <andreyknvl@google.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Alexander Potapenko <glider@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:

committed by
Linus Torvalds

parent
c59180ae3e
commit
ae8f06b31a
@@ -95,9 +95,19 @@ struct kasan_track {
|
||||
depot_stack_handle_t stack;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_KASAN_SW_TAGS_IDENTIFY
|
||||
#define KASAN_NR_FREE_STACKS 5
|
||||
#else
|
||||
#define KASAN_NR_FREE_STACKS 1
|
||||
#endif
|
||||
|
||||
struct kasan_alloc_meta {
|
||||
struct kasan_track alloc_track;
|
||||
struct kasan_track free_track;
|
||||
struct kasan_track free_track[KASAN_NR_FREE_STACKS];
|
||||
#ifdef CONFIG_KASAN_SW_TAGS_IDENTIFY
|
||||
u8 free_pointer_tag[KASAN_NR_FREE_STACKS];
|
||||
u8 free_track_idx;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct qlist_node {
|
||||
@@ -146,6 +156,8 @@ void kasan_report(unsigned long addr, size_t size,
|
||||
bool is_write, unsigned long ip);
|
||||
void kasan_report_invalid_free(void *object, unsigned long ip);
|
||||
|
||||
struct page *kasan_addr_to_page(const void *addr);
|
||||
|
||||
#if defined(CONFIG_KASAN_GENERIC) && \
|
||||
(defined(CONFIG_SLAB) || defined(CONFIG_SLUB))
|
||||
void quarantine_put(struct kasan_free_meta *info, struct kmem_cache *cache);
|
||||
|
Reference in New Issue
Block a user