linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 4.9 1/8] perf/core: Fix perf_sample_regs_user() mm check
@ 2019-07-03  2:18 Sasha Levin
  2019-07-03  2:18 ` [PATCH AUTOSEL 4.9 2/8] ARM: omap2: remove incorrect __init annotation Sasha Levin
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Sasha Levin @ 2019-07-03  2:18 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Peter Zijlstra, Ravi Bangoria, Young Xiao, Will Deacon,
	Arnaldo Carvalho de Melo, Frederic Weisbecker, Jiri Olsa,
	Linus Torvalds, Michael Ellerman, Naveen N . Rao,
	Stephane Eranian, Thomas Gleixner, Ingo Molnar, Sasha Levin

From: Peter Zijlstra <peterz@infradead.org>

[ Upstream commit 085ebfe937d7a7a5df1729f35a12d6d655fea68c ]

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 <ravi.bangoria@linux.vnet.ibm.com>
Reported-by: Young Xiao <92siuyang@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Will Deacon <will.deacon@arm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: 4018994f3d87 ("perf: Add ability to attach user level registers dump to sample")
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/events/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 7929526e96e2..93d7333c64d8 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -5492,7 +5492,7 @@ static void perf_sample_regs_user(struct perf_regs *regs_user,
 	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;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-07-03  2:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-03  2:18 [PATCH AUTOSEL 4.9 1/8] perf/core: Fix perf_sample_regs_user() mm check Sasha Levin
2019-07-03  2:18 ` [PATCH AUTOSEL 4.9 2/8] ARM: omap2: remove incorrect __init annotation Sasha Levin
2019-07-03  2:18 ` [PATCH AUTOSEL 4.9 3/8] be2net: fix link failure after ethtool offline test Sasha Levin
2019-07-03  2:18 ` [PATCH AUTOSEL 4.9 4/8] ppp: mppe: Add softdep to arc4 Sasha Levin
2019-07-03  2:18 ` [PATCH AUTOSEL 4.9 5/8] net: stmmac: fixed new system time seconds value calculation Sasha Levin
2019-07-03  2:18 ` [PATCH AUTOSEL 4.9 6/8] sis900: fix TX completion Sasha Levin
2019-07-03  2:18 ` [PATCH AUTOSEL 4.9 7/8] ARM: dts: imx6ul: fix PWM[1-4] interrupts Sasha Levin
2019-07-03  2:18 ` [PATCH AUTOSEL 4.9 8/8] dm verity: use message limit for data block corruption message Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).