Skip to content
Permalink
Browse files
fix! kasan: add kasan_async_mode_enabled
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
  • Loading branch information
xairy committed Feb 11, 2021
1 parent 22cd50b commit 91354d34b30ceedbc1b6417f1ff253de90618a97
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
@@ -51,7 +51,7 @@ static int kasan_test_init(struct kunit *test)
kunit_err(test, "can't run KASAN tests with KASAN disabled");
return -1;
}
if (kasan_flag_async) {
if (kasan_async_mode_enabled()) {
kunit_err(test, "can't run KASAN tests in async mode");
return -1;
}
@@ -7,21 +7,37 @@
#include <linux/stackdepot.h>

#ifdef CONFIG_KASAN_HW_TAGS

#include <linux/static_key.h>

DECLARE_STATIC_KEY_FALSE(kasan_flag_stacktrace);
extern bool kasan_flag_async __ro_after_init;

static inline bool kasan_stack_collection_enabled(void)
{
return static_branch_unlikely(&kasan_flag_stacktrace);
}

static inline bool kasan_async_mode_enabled(void)
{
return kasan_flag_async;
}

#else

static inline bool kasan_stack_collection_enabled(void)
{
return true;
}

static inline bool kasan_async_mode_enabled(void)
{
return false;
}

#endif

extern bool kasan_flag_panic __ro_after_init;
extern bool kasan_flag_async __ro_after_init;

#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
#define KASAN_GRANULE_SIZE (1UL << KASAN_SHADOW_SCALE_SHIFT)
@@ -87,7 +87,7 @@ static void start_report(unsigned long *flags)

static void end_report(unsigned long *flags, unsigned long addr)
{
if (!kasan_flag_async)
if (!kasan_async_mode_enabled())
trace_error_report_end(ERROR_DETECTOR_KASAN, addr);
pr_err("==================================================================\n");
add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);

0 comments on commit 91354d3

Please sign in to comment.