mirror of https://gitee.com/openkylin/linux.git
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 <leon@kernel.org> Signed-off-by: Andrey Konovalov <andreyknvl@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Tested-by: Leon Romanovsky <leon@kernel.org> Cc: Andrey Ryabinin <aryabinin@virtuozzo.com> Cc: Alexander Potapenko <glider@google.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Leon Romanovsky <leonro@mellanox.com> Link: http://lkml.kernel.org/r/78a81fde6eeda9db72a7fd55fbc33173a515e4b1.1589297433.git.andreyknvl@google.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
86fea8b494
commit
4fba37586e
|
@ -33,7 +33,6 @@
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
#include <linux/vmalloc.h>
|
#include <linux/vmalloc.h>
|
||||||
#include <linux/bug.h>
|
#include <linux/bug.h>
|
||||||
#include <linux/uaccess.h>
|
|
||||||
|
|
||||||
#include <asm/cacheflush.h>
|
#include <asm/cacheflush.h>
|
||||||
#include <asm/tlbflush.h>
|
#include <asm/tlbflush.h>
|
||||||
|
@ -613,24 +612,6 @@ void kasan_free_shadow(const struct vm_struct *vm)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void __kasan_report(unsigned long addr, size_t size, bool is_write, unsigned long ip);
|
|
||||||
extern bool report_enabled(void);
|
|
||||||
|
|
||||||
bool kasan_report(unsigned long addr, size_t size, bool is_write, unsigned long ip)
|
|
||||||
{
|
|
||||||
unsigned long flags = user_access_save();
|
|
||||||
bool ret = false;
|
|
||||||
|
|
||||||
if (likely(report_enabled())) {
|
|
||||||
__kasan_report(addr, size, is_write, ip);
|
|
||||||
ret = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
user_access_restore(flags);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_MEMORY_HOTPLUG
|
#ifdef CONFIG_MEMORY_HOTPLUG
|
||||||
static bool shadow_mapped(unsigned long addr)
|
static bool shadow_mapped(unsigned long addr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <linux/kasan.h>
|
#include <linux/kasan.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/sched/task_stack.h>
|
#include <linux/sched/task_stack.h>
|
||||||
|
#include <linux/uaccess.h>
|
||||||
|
|
||||||
#include <asm/sections.h>
|
#include <asm/sections.h>
|
||||||
|
|
||||||
|
@ -454,7 +455,7 @@ static void print_shadow_for_address(const void *addr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool report_enabled(void)
|
static bool report_enabled(void)
|
||||||
{
|
{
|
||||||
if (current->kasan_depth)
|
if (current->kasan_depth)
|
||||||
return false;
|
return false;
|
||||||
|
@ -479,7 +480,8 @@ void kasan_report_invalid_free(void *object, unsigned long ip)
|
||||||
end_report(&flags);
|
end_report(&flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __kasan_report(unsigned long addr, size_t size, bool is_write, unsigned long ip)
|
static void __kasan_report(unsigned long addr, size_t size, bool is_write,
|
||||||
|
unsigned long ip)
|
||||||
{
|
{
|
||||||
struct kasan_access_info info;
|
struct kasan_access_info info;
|
||||||
void *tagged_addr;
|
void *tagged_addr;
|
||||||
|
@ -518,6 +520,22 @@ void __kasan_report(unsigned long addr, size_t size, bool is_write, unsigned lon
|
||||||
end_report(&flags);
|
end_report(&flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool kasan_report(unsigned long addr, size_t size, bool is_write,
|
||||||
|
unsigned long ip)
|
||||||
|
{
|
||||||
|
unsigned long flags = user_access_save();
|
||||||
|
bool ret = false;
|
||||||
|
|
||||||
|
if (likely(report_enabled())) {
|
||||||
|
__kasan_report(addr, size, is_write, ip);
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
user_access_restore(flags);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_KASAN_INLINE
|
#ifdef CONFIG_KASAN_INLINE
|
||||||
/*
|
/*
|
||||||
* With CONFIG_KASAN_INLINE, accesses to bogus pointers (outside the high
|
* With CONFIG_KASAN_INLINE, accesses to bogus pointers (outside the high
|
||||||
|
|
Loading…
Reference in New Issue