[PATCH 10/18] vchecker: Use __GFP_ATOMIC to save stacktrace

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


From: Namhyung Kim <namhyung@xxxxxxxxxx>

Since we're finding a cause of broken data, it'd be desired not to miss
any suspects. It doesn't use GFP_ATOMIC since it includes __GFP_HIGH
which is for system making forward progress.

It also adds a WARN_ON whenever it fails to allocate pages even with
__GFP_ATOMIC.

Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx>
---
mm/kasan/vchecker.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/mm/kasan/vchecker.c b/mm/kasan/vchecker.c
index 6b3824f..df480d5 100644
--- a/mm/kasan/vchecker.c
+++ b/mm/kasan/vchecker.c
@@ -301,13 +301,20 @@ static noinline depot_stack_handle_t save_stack(int skip, bool *is_new)
.max_entries = VCHECKER_STACK_DEPTH,
.skip = skip,
};
+ depot_stack_handle_t handle;

save_stack_trace(&trace);
if (trace.nr_entries != 0 &&
trace.entries[trace.nr_entries-1] == ULONG_MAX)
trace.nr_entries--;

- return depot_save_stack(NULL, &trace, GFP_NOWAIT, is_new);
+ if (trace.nr_entries == 0)
+ return 0;
+
+ handle = depot_save_stack(NULL, &trace, __GFP_ATOMIC, is_new);
+ WARN_ON(!handle);
+
+ return handle;
}

static ssize_t vchecker_type_write(struct file *filp, const char __user *ubuf,
--
2.7.4