[PATCH 13/18] mm/vchecker: support inline KASAN build

From: js1304
Date: Tue Nov 28 2017 - 02:50:15 EST


From: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx>

There is no reason not to support inline KASAN build. Support it.

Note that vchecker_check() function is now placed on kasan report function
to support inline build because gcc generates the inline check code and
then directly jump to kasan report function when poisoned value is found.
Name is somewhat misleading but there is no problem in the view of
implementation.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx>
---
lib/Kconfig.kasan | 1 -
mm/kasan/report.c | 8 ++++++++
2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan
index 51c0a05..d3552f3 100644
--- a/lib/Kconfig.kasan
+++ b/lib/Kconfig.kasan
@@ -63,6 +63,5 @@ config VCHECKER
happens at the area.

depends on KASAN && DEBUG_FS
- select KASAN_OUTLINE

endif
diff --git a/mm/kasan/report.c b/mm/kasan/report.c
index 6c83631..3d002aa 100644
--- a/mm/kasan/report.c
+++ b/mm/kasan/report.c
@@ -413,6 +413,8 @@ void kasan_report(unsigned long addr, size_t size,
#define DEFINE_ASAN_REPORT_LOAD(size) \
void __asan_report_load##size##_noabort(unsigned long addr) \
{ \
+ if (vchecker_check(addr, size, false, _RET_IP_)) \
+ return; \
kasan_report(addr, size, false, _RET_IP_); \
} \
EXPORT_SYMBOL(__asan_report_load##size##_noabort)
@@ -420,6 +422,8 @@ EXPORT_SYMBOL(__asan_report_load##size##_noabort)
#define DEFINE_ASAN_REPORT_STORE(size) \
void __asan_report_store##size##_noabort(unsigned long addr) \
{ \
+ if (vchecker_check(addr, size, true, _RET_IP_)) \
+ return; \
kasan_report(addr, size, true, _RET_IP_); \
} \
EXPORT_SYMBOL(__asan_report_store##size##_noabort)
@@ -437,12 +441,16 @@ DEFINE_ASAN_REPORT_STORE(16);

void __asan_report_load_n_noabort(unsigned long addr, size_t size)
{
+ if (vchecker_check(addr, size, false, _RET_IP_))
+ return;
kasan_report(addr, size, false, _RET_IP_);
}
EXPORT_SYMBOL(__asan_report_load_n_noabort);

void __asan_report_store_n_noabort(unsigned long addr, size_t size)
{
+ if (vchecker_check(addr, size, true, _RET_IP_))
+ return;
kasan_report(addr, size, true, _RET_IP_);
}
EXPORT_SYMBOL(__asan_report_store_n_noabort);
--
2.7.4