On Wed, May 29, 2019 at 11:20:22AM +0100, Will Deacon wrote: > Anyway, you can add my ack to your patch, but I bet we can remove that mm > check :D
I've ended up with the below. Ravi, can you test if that does indeed obsolete your PPC patch? --- Subject: perf: Fix perf_sample_regs_user() From: Peter Zijlstra <[email protected]> Date: Wed May 29 14:37:24 CEST 2019 perf_sample_regs_user() uses 'current->mm' to test for the presence of userspace, but this is insufficient, consider use_mm(). A better test is: '!(current->flags & PF_KTHREAD)', exec() clears PF_KTHREAD after it sets the new ->mm but before it drops to userspace for the first time. Possibly obsoletes: bf05fc25f268 ("powerpc/perf: Fix oops when kthread execs user process") Reported-by: Ravi Bangoria <[email protected]> Reported-by: Young Xiao <[email protected]> Cc: Ravi Bangoria <[email protected]> Cc: Naveen N. Rao <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Acked-by: Will Deacon <[email protected]> Fixes: 4018994f3d87 ("perf: Add ability to attach user level registers dump to sample") Signed-off-by: Peter Zijlstra (Intel) <[email protected]> --- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -5923,7 +5923,7 @@ static void perf_sample_regs_user(struct if (user_mode(regs)) { regs_user->abi = perf_reg_abi(current); regs_user->regs = regs; - } else if (current->mm) { + } else if (!(current->flags & PF_KTHREAD)) { perf_get_regs_user(regs_user, regs, regs_user_copy); } else { regs_user->abi = PERF_SAMPLE_REGS_ABI_NONE;

