From 0617ae1b2c9b9055535aaf08ecbaf35a9cc16172 Mon Sep 17 00:00:00 2001 From: Jan Stancek Date: Thu, 26 Jun 2014 14:41:43 +0200 Subject: [PATCH] kmod/core: be more verbose when activness safety check fails Print some basic info and stack trace for task when activness safety check fails. Signed-off-by: Jan Stancek --- kmod/core/core.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/kmod/core/core.c b/kmod/core/core.c index 5c09174..bf8f53c 100644 --- a/kmod/core/core.c +++ b/kmod/core/core.c @@ -247,6 +247,25 @@ static const struct stacktrace_ops kpatch_backtrace_ops = { .walk_stack = print_context_stack_bp, }; +static int kpatch_print_trace_stack(void *data, char *name) +{ + pr_cont(" <%s> ", name); + return 0; +} + +static void kpatch_print_trace_address(void *data, unsigned long addr, + int reliable) +{ + if (reliable) + pr_info("[<%p>] %pB\n", (void *)addr, (void *)addr); +} + +static const struct stacktrace_ops kpatch_print_trace_ops = { + .stack = kpatch_print_trace_stack, + .address = kpatch_print_trace_address, + .walk_stack = print_context_stack, +}; + /* * Verify activeness safety, i.e. that none of the to-be-patched functions are * on the stack of any task. @@ -268,6 +287,9 @@ static int kpatch_verify_activeness_safety(struct kpatch_module *kpmod) dump_trace(t, NULL, NULL, 0, &kpatch_backtrace_ops, &args); if (args.ret) { ret = args.ret; + pr_info("PID: %d Comm: %.20s\n", t->pid, t->comm); + dump_trace(t, NULL, (unsigned long *)t->thread.sp, + 0, &kpatch_print_trace_ops, NULL); goto out; } } while_each_thread(g, t);