Skip to content

Commit 4fba375

Browse files
xairytorvalds
authored andcommitted
kasan: move kasan_report() into report.c
The kasan_report() functions belongs to report.c, as it's a common functions that does error reporting. Reported-by: Leon Romanovsky <[email protected]> Signed-off-by: Andrey Konovalov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Tested-by: Leon Romanovsky <[email protected]> Cc: Andrey Ryabinin <[email protected]> Cc: Alexander Potapenko <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: Leon Romanovsky <[email protected]> Link: http://lkml.kernel.org/r/78a81fde6eeda9db72a7fd55fbc33173a515e4b1.1589297433.git.andreyknvl@google.com Signed-off-by: Linus Torvalds <[email protected]>
1 parent 86fea8b commit 4fba375

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

mm/kasan/common.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include <linux/types.h>
3434
#include <linux/vmalloc.h>
3535
#include <linux/bug.h>
36-
#include <linux/uaccess.h>
3736

3837
#include <asm/cacheflush.h>
3938
#include <asm/tlbflush.h>
@@ -613,24 +612,6 @@ void kasan_free_shadow(const struct vm_struct *vm)
613612
}
614613
#endif
615614

616-
extern void __kasan_report(unsigned long addr, size_t size, bool is_write, unsigned long ip);
617-
extern bool report_enabled(void);
618-
619-
bool kasan_report(unsigned long addr, size_t size, bool is_write, unsigned long ip)
620-
{
621-
unsigned long flags = user_access_save();
622-
bool ret = false;
623-
624-
if (likely(report_enabled())) {
625-
__kasan_report(addr, size, is_write, ip);
626-
ret = true;
627-
}
628-
629-
user_access_restore(flags);
630-
631-
return ret;
632-
}
633-
634615
#ifdef CONFIG_MEMORY_HOTPLUG
635616
static bool shadow_mapped(unsigned long addr)
636617
{

mm/kasan/report.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <linux/kasan.h>
3030
#include <linux/module.h>
3131
#include <linux/sched/task_stack.h>
32+
#include <linux/uaccess.h>
3233

3334
#include <asm/sections.h>
3435

@@ -454,7 +455,7 @@ static void print_shadow_for_address(const void *addr)
454455
}
455456
}
456457

457-
bool report_enabled(void)
458+
static bool report_enabled(void)
458459
{
459460
if (current->kasan_depth)
460461
return false;
@@ -479,7 +480,8 @@ void kasan_report_invalid_free(void *object, unsigned long ip)
479480
end_report(&flags);
480481
}
481482

482-
void __kasan_report(unsigned long addr, size_t size, bool is_write, unsigned long ip)
483+
static void __kasan_report(unsigned long addr, size_t size, bool is_write,
484+
unsigned long ip)
483485
{
484486
struct kasan_access_info info;
485487
void *tagged_addr;
@@ -518,6 +520,22 @@ void __kasan_report(unsigned long addr, size_t size, bool is_write, unsigned lon
518520
end_report(&flags);
519521
}
520522

523+
bool kasan_report(unsigned long addr, size_t size, bool is_write,
524+
unsigned long ip)
525+
{
526+
unsigned long flags = user_access_save();
527+
bool ret = false;
528+
529+
if (likely(report_enabled())) {
530+
__kasan_report(addr, size, is_write, ip);
531+
ret = true;
532+
}
533+
534+
user_access_restore(flags);
535+
536+
return ret;
537+
}
538+
521539
#ifdef CONFIG_KASAN_INLINE
522540
/*
523541
* With CONFIG_KASAN_INLINE, accesses to bogus pointers (outside the high

0 commit comments

Comments
 (0)