aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Konovalov <andreyknvl@google.com>2017-05-03 17:56:28 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-05-03 18:52:12 -0400
commit7d418f7b0d3407b93ec70f3b380cc5beafa1fa68 (patch)
tree865aab1d0e830a6356b79079b073ee2d2f01ecff
parent5e82cd120382ad7bbcc82298e34a034538b4384c (diff)
kasan: unify report headers
Unify KASAN report header format for different kinds of bad memory accesses. Makes the code simpler. Link: http://lkml.kernel.org/r/20170302134851.101218-3-andreyknvl@google.com Signed-off-by: Andrey Konovalov <andreyknvl@google.com> Acked-by: Dmitry Vyukov <dvyukov@google.com> Cc: Andrey Ryabinin <aryabinin@virtuozzo.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>
-rw-r--r--mm/kasan/report.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/mm/kasan/report.c b/mm/kasan/report.c
index c2bc08b1b5e0..d6b6ec77c56a 100644
--- a/mm/kasan/report.c
+++ b/mm/kasan/report.c
@@ -121,16 +121,22 @@ const char *get_wild_bug_type(struct kasan_access_info *info)
121 return bug_type; 121 return bug_type;
122} 122}
123 123
124static const char *get_bug_type(struct kasan_access_info *info)
125{
126 if (addr_has_shadow(info))
127 return get_shadow_bug_type(info);
128 return get_wild_bug_type(info);
129}
130
124static void print_error_description(struct kasan_access_info *info) 131static void print_error_description(struct kasan_access_info *info)
125{ 132{
126 const char *bug_type = get_shadow_bug_type(info); 133 const char *bug_type = get_bug_type(info);
127 134
128 pr_err("BUG: KASAN: %s in %pS at addr %p\n", 135 pr_err("BUG: KASAN: %s in %pS at addr %p\n",
129 bug_type, (void *)info->ip, 136 bug_type, (void *)info->ip, info->access_addr);
130 info->access_addr);
131 pr_err("%s of size %zu by task %s/%d\n", 137 pr_err("%s of size %zu by task %s/%d\n",
132 info->is_write ? "Write" : "Read", 138 info->is_write ? "Write" : "Read", info->access_size,
133 info->access_size, current->comm, task_pid_nr(current)); 139 current->comm, task_pid_nr(current));
134} 140}
135 141
136static inline bool kernel_or_module_addr(const void *addr) 142static inline bool kernel_or_module_addr(const void *addr)
@@ -297,17 +303,11 @@ static void kasan_report_error(struct kasan_access_info *info)
297 303
298 kasan_start_report(&flags); 304 kasan_start_report(&flags);
299 305
306 print_error_description(info);
307
300 if (!addr_has_shadow(info)) { 308 if (!addr_has_shadow(info)) {
301 const char *bug_type = get_wild_bug_type(info);
302 pr_err("BUG: KASAN: %s on address %p\n",
303 bug_type, info->access_addr);
304 pr_err("%s of size %zu by task %s/%d\n",
305 info->is_write ? "Write" : "Read",
306 info->access_size, current->comm,
307 task_pid_nr(current));
308 dump_stack(); 309 dump_stack();
309 } else { 310 } else {
310 print_error_description(info);
311 print_address_description(info); 311 print_address_description(info);
312 print_shadow_for_address(info->first_bad_addr); 312 print_shadow_for_address(info->first_bad_addr);
313 } 313 }