Skip to content

Commit

Permalink
kasan: more line breaks in reports
Browse files Browse the repository at this point in the history
Add a line break after each part that describes the buggy address.
Improves readability of reports.

Link: https://lkml.kernel.org/r/8682c4558e533cd0f99bdb964ce2fe741f2a9212.1646237226.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <[email protected]>
Reviewed-by: Alexander Potapenko <[email protected]>
Cc: Andrey Ryabinin <[email protected]>
Cc: Dmitry Vyukov <[email protected]>
Cc: Marco Elver <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
xairy authored and torvalds committed Mar 25, 2022
1 parent 7131c88 commit 038fd2b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mm/kasan/report.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,13 @@ static void print_address_description(void *addr, u8 tag)
void *object = nearest_obj(cache, slab, addr);

describe_object(cache, object, addr, tag);
pr_err("\n");
}

if (kernel_or_module_addr(addr) && !init_task_stack_addr(addr)) {
pr_err("The buggy address belongs to the variable:\n");
pr_err(" %pS\n", addr);
pr_err("\n");
}

if (is_vmalloc_addr(addr)) {
Expand All @@ -265,6 +267,7 @@ static void print_address_description(void *addr, u8 tag)
" [%px, %px) created by:\n"
" %pS\n",
va->addr, va->addr + va->size, va->caller);
pr_err("\n");

page = vmalloc_to_page(page);
}
Expand All @@ -273,9 +276,11 @@ static void print_address_description(void *addr, u8 tag)
if (page) {
pr_err("The buggy address belongs to the physical page:\n");
dump_page(page, "kasan: bad access detected");
pr_err("\n");
}

kasan_print_address_stack_frame(addr);
pr_err("\n");
}

static bool meta_row_is_guilty(const void *row, const void *addr)
Expand Down Expand Up @@ -382,7 +387,6 @@ void kasan_report_invalid_free(void *object, unsigned long ip)
kasan_print_tags(tag, object);
pr_err("\n");
print_address_description(object, tag);
pr_err("\n");
print_memory_metadata(object);
end_report(&flags, (unsigned long)object);
}
Expand Down Expand Up @@ -443,7 +447,6 @@ static void __kasan_report(unsigned long addr, size_t size, bool is_write,

if (addr_has_metadata(untagged_addr)) {
print_address_description(untagged_addr, get_tag(tagged_addr));
pr_err("\n");
print_memory_metadata(info.first_bad_addr);
} else {
dump_stack_lvl(KERN_ERR);
Expand Down

0 comments on commit 038fd2b

Please sign in to comment.