diff options
author | Andrey Konovalov <andreyknvl@google.com> | 2020-12-22 12:00:39 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2020-12-22 12:55:06 -0800 |
commit | 59fd51b2ba6b02e0f7c989fc12c3537988f8c8fe (patch) | |
tree | f086e90b268790974c2f3e430fb6d351dd7a5a16 /mm/kasan/tags_report.c | |
parent | affc3f07759cfdcb1ffd87f2847b1c27d8781d65 (diff) |
kasan: rename report and tags files
Rename generic_report.c to report_generic.c and tags_report.c to
report_sw_tags.c, as their content is more relevant to report.c file.
Also rename tags.c to sw_tags.c to better reflect that this file contains
code for software tag-based mode.
No functional changes.
Link: https://lkml.kernel.org/r/a6105d416da97d389580015afed66c4c3cfd4c08.1606161801.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Reviewed-by: Marco Elver <elver@google.com>
Reviewed-by: Alexander Potapenko <glider@google.com>
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Branislav Rankov <Branislav.Rankov@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Evgenii Stepanov <eugenis@google.com>
Cc: Kevin Brodsky <kevin.brodsky@arm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/kasan/tags_report.c')
-rw-r--r-- | mm/kasan/tags_report.c | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/mm/kasan/tags_report.c b/mm/kasan/tags_report.c deleted file mode 100644 index c87d5a343b4e..000000000000 --- a/mm/kasan/tags_report.c +++ /dev/null @@ -1,88 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * This file contains tag-based KASAN specific error reporting code. - * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * Author: Andrey Ryabinin <ryabinin.a.a@gmail.com> - * - * Some code borrowed from https://github.com/xairy/kasan-prototype by - * Andrey Konovalov <andreyknvl@gmail.com> - */ - -#include <linux/bitops.h> -#include <linux/ftrace.h> -#include <linux/init.h> -#include <linux/kernel.h> -#include <linux/mm.h> -#include <linux/printk.h> -#include <linux/sched.h> -#include <linux/slab.h> -#include <linux/stackdepot.h> -#include <linux/stacktrace.h> -#include <linux/string.h> -#include <linux/types.h> -#include <linux/kasan.h> -#include <linux/module.h> - -#include <asm/sections.h> - -#include "kasan.h" -#include "../slab.h" - -const char *get_bug_type(struct kasan_access_info *info) -{ -#ifdef CONFIG_KASAN_SW_TAGS_IDENTIFY - struct kasan_alloc_meta *alloc_meta; - struct kmem_cache *cache; - struct page *page; - const void *addr; - void *object; - u8 tag; - int i; - - tag = get_tag(info->access_addr); - addr = reset_tag(info->access_addr); - page = kasan_addr_to_page(addr); - if (page && PageSlab(page)) { - cache = page->slab_cache; - object = nearest_obj(cache, page, (void *)addr); - alloc_meta = get_alloc_info(cache, object); - - for (i = 0; i < KASAN_NR_FREE_STACKS; i++) - if (alloc_meta->free_pointer_tag[i] == tag) - return "use-after-free"; - return "out-of-bounds"; - } - -#endif - /* - * If access_size is a negative number, then it has reason to be - * defined as out-of-bounds bug type. - * - * Casting negative numbers to size_t would indeed turn up as - * a large size_t and its value will be larger than ULONG_MAX/2, - * so that this can qualify as out-of-bounds. - */ - if (info->access_addr + info->access_size < info->access_addr) - return "out-of-bounds"; - - return "invalid-access"; -} - -void *find_first_bad_addr(void *addr, size_t size) -{ - u8 tag = get_tag(addr); - void *p = reset_tag(addr); - void *end = p + size; - - while (p < end && tag == *(u8 *)kasan_mem_to_shadow(p)) - p += KASAN_GRANULE_SIZE; - return p; -} - -void print_tags(u8 addr_tag, const void *addr) -{ - u8 *shadow = (u8 *)kasan_mem_to_shadow(addr); - - pr_err("Pointer tag: [%02x], memory tag: [%02x]\n", addr_tag, *shadow); -} |