Re: [PATCH v3 0/6] Tracing vs CR2

From: Vegard Nossum
Date: Wed Jul 17 2019 - 04:12:21 EST


On 7/17/19 10:07 AM, Peter Zijlstra wrote:
On Tue, Jul 16, 2019 at 09:33:50PM +0200, Vegard Nossum wrote:
------------[ cut here ]------------
General protection fault in user access. Non-canonical address?
WARNING: CPU: 0 PID: 5039 at arch/x86/mm/extable.c:126
ex_handler_uaccess+0x5d/0x70
[...]


https://lkml.kernel.org/r/57754f11-2c65-a2c8-2f6d-bfab0d2f8b53@xxxxxxxxxxxx

Does something like the below help?

diff --git a/kernel/stacktrace.c b/kernel/stacktrace.c
index c8d0f05721a1..80ad4ccb7025 100644
--- a/kernel/stacktrace.c
+++ b/kernel/stacktrace.c
@@ -226,12 +226,16 @@ unsigned int stack_trace_save_user(unsigned long *store, unsigned int size)
.store = store,
.size = size,
};
+ mm_segment_t fs;
/* Trace user stack if not a kernel thread */
if (current->flags & PF_KTHREAD)
return 0;
+ fs = get_fs();
+ set_fs(USER_DS);
arch_stack_walk_user(consume_entry, &c, task_pt_regs(current));
+ set_fs(fs);
return c.len;
}
#endif


Yes.


Vegard