Commit | Line | Data |
---|---|---|
e886bf9d | 1 | // SPDX-License-Identifier: GPL-2.0 |
11cd3cd6 AK |
2 | /* |
3 | * This file contains tag-based KASAN specific error reporting code. | |
4 | * | |
5 | * Copyright (c) 2014 Samsung Electronics Co., Ltd. | |
6 | * Author: Andrey Ryabinin <ryabinin.a.a@gmail.com> | |
7 | * | |
8 | * Some code borrowed from https://github.com/xairy/kasan-prototype by | |
9 | * Andrey Konovalov <andreyknvl@gmail.com> | |
10 | * | |
11 | * This program is free software; you can redistribute it and/or modify | |
12 | * it under the terms of the GNU General Public License version 2 as | |
13 | * published by the Free Software Foundation. | |
14 | * | |
15 | */ | |
16 | ||
17 | #include <linux/bitops.h> | |
18 | #include <linux/ftrace.h> | |
19 | #include <linux/init.h> | |
20 | #include <linux/kernel.h> | |
21 | #include <linux/mm.h> | |
22 | #include <linux/printk.h> | |
23 | #include <linux/sched.h> | |
24 | #include <linux/slab.h> | |
25 | #include <linux/stackdepot.h> | |
26 | #include <linux/stacktrace.h> | |
27 | #include <linux/string.h> | |
28 | #include <linux/types.h> | |
29 | #include <linux/kasan.h> | |
30 | #include <linux/module.h> | |
31 | ||
32 | #include <asm/sections.h> | |
33 | ||
34 | #include "kasan.h" | |
35 | #include "../slab.h" | |
36 | ||
37 | const char *get_bug_type(struct kasan_access_info *info) | |
38 | { | |
39 | return "invalid-access"; | |
40 | } | |
121e8f81 AK |
41 | |
42 | void *find_first_bad_addr(void *addr, size_t size) | |
43 | { | |
44 | u8 tag = get_tag(addr); | |
45 | void *p = reset_tag(addr); | |
46 | void *end = p + size; | |
47 | ||
48 | while (p < end && tag == *(u8 *)kasan_mem_to_shadow(p)) | |
49 | p += KASAN_SHADOW_SCALE_SIZE; | |
50 | return p; | |
51 | } | |
52 | ||
53 | void print_tags(u8 addr_tag, const void *addr) | |
54 | { | |
55 | u8 *shadow = (u8 *)kasan_mem_to_shadow(addr); | |
56 | ||
57 | pr_err("Pointer tag: [%02x], memory tag: [%02x]\n", addr_tag, *shadow); | |
58 | } |