[PATCH] mm/kasan: fix-up CONFIG_KASAN_INLINE

From: Joonsoo Kim
Date: Tue May 16 2017 - 01:56:27 EST


Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx>
---
mm/kasan/kasan.c | 13 +++++++++++--
mm/kasan/kasan.h | 2 ++
mm/kasan/report.c | 2 +-
3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
index 76c1c37..fd6b7d4 100644
--- a/mm/kasan/kasan.c
+++ b/mm/kasan/kasan.c
@@ -622,7 +622,7 @@ static noinline void check_memory_region_slow(unsigned long addr,

report:
preempt_enable();
- kasan_report(addr, size, write, ret_ip);
+ __kasan_report(addr, size, write, ret_ip);
}

static __always_inline void check_memory_region_inline(unsigned long addr,
@@ -634,7 +634,7 @@ static __always_inline void check_memory_region_inline(unsigned long addr,

if (unlikely((void *)addr <
kasan_shadow_to_mem((void *)KASAN_SHADOW_START))) {
- kasan_report(addr, size, write, ret_ip);
+ __kasan_report(addr, size, write, ret_ip);
return;
}

@@ -692,6 +692,15 @@ void *memcpy(void *dest, const void *src, size_t len)
return __memcpy(dest, src, len);
}

+void kasan_report(unsigned long addr, size_t size,
+ bool is_write, unsigned long ip)
+{
+ if (!pshadow_val(addr, size))
+ return;
+
+ check_memory_region_slow(addr, size, is_write, ip);
+}
+
void kasan_alloc_pages(struct page *page, unsigned int order)
{
if (likely(!PageHighMem(page))) {
diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h
index db04087..7a20707 100644
--- a/mm/kasan/kasan.h
+++ b/mm/kasan/kasan.h
@@ -108,6 +108,8 @@ static inline bool arch_kasan_recheck_prepare(unsigned long addr,
static inline bool kasan_pshadow_inited(void) { return false; }
#endif

+void __kasan_report(unsigned long addr, size_t size,
+ bool is_write, unsigned long ip);
void kasan_report(unsigned long addr, size_t size,
bool is_write, unsigned long ip);
void kasan_report_double_free(struct kmem_cache *cache, void *object,
diff --git a/mm/kasan/report.c b/mm/kasan/report.c
index 9b47e10..7831d58 100644
--- a/mm/kasan/report.c
+++ b/mm/kasan/report.c
@@ -418,7 +418,7 @@ static inline bool kasan_report_enabled(void)
return !test_and_set_bit(KASAN_BIT_REPORTED, &kasan_flags);
}

-void kasan_report(unsigned long addr, size_t size,
+void __kasan_report(unsigned long addr, size_t size,
bool is_write, unsigned long ip)
{
struct kasan_access_info info;
--
2.7.4