public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>,
	Young Xiao <92siuyang@gmail.com>,
	Will Deacon <will.deacon@arm.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Jiri Olsa <jolsa@redhat.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	"Naveen N . Rao" <naveen.n.rao@linux.vnet.ibm.com>,
	Stephane Eranian <eranian@google.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>, Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 4.14 03/13] perf/core: Fix perf_sample_regs_user() mm check
Date: Tue,  2 Jul 2019 22:18:04 -0400	[thread overview]
Message-ID: <20190703021814.18385-3-sashal@kernel.org> (raw)
In-Reply-To: <20190703021814.18385-1-sashal@kernel.org>

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 580616e6fcee..3d4eb6f840eb 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -5630,7 +5630,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


  parent reply	other threads:[~2019-07-03  2:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-03  2:18 [PATCH AUTOSEL 4.14 01/13] clk: ti: clkctrl: Fix returning uninitialized data Sasha Levin
2019-07-03  2:18 ` [PATCH AUTOSEL 4.14 02/13] efi/bgrt: Drop BGRT status field reserved bits check Sasha Levin
2019-07-03  2:18 ` Sasha Levin [this message]
2019-07-03  2:18 ` [PATCH AUTOSEL 4.14 04/13] ARM: omap2: remove incorrect __init annotation Sasha Levin
2019-07-03  2:18 ` [PATCH AUTOSEL 4.14 05/13] be2net: fix link failure after ethtool offline test Sasha Levin
2019-07-03  2:18 ` [PATCH AUTOSEL 4.14 06/13] ppp: mppe: Add softdep to arc4 Sasha Levin
2019-07-03  2:18 ` [PATCH AUTOSEL 4.14 07/13] net: stmmac: fixed new system time seconds value calculation Sasha Levin
2019-07-03  2:18 ` [PATCH AUTOSEL 4.14 08/13] sis900: fix TX completion Sasha Levin
2019-07-03  2:18 ` [PATCH AUTOSEL 4.14 09/13] ARM: dts: imx6ul: fix PWM[1-4] interrupts Sasha Levin
2019-07-03  2:18 ` [PATCH AUTOSEL 4.14 10/13] dm verity: use message limit for data block corruption message Sasha Levin
2019-07-03  2:18 ` [PATCH AUTOSEL 4.14 11/13] x86/boot/64: Fix crash if kernel image crosses page table boundary Sasha Levin
2019-07-03  2:18 ` [PATCH AUTOSEL 4.14 12/13] cpu/hotplug: Fix out-of-bounds read when setting fail state Sasha Levin
2019-07-03  2:18 ` [PATCH AUTOSEL 4.14 13/13] linux/kernel.h: fix overflow for DIV_ROUND_UP_ULL Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190703021814.18385-3-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=92siuyang@gmail.com \
    --cc=acme@redhat.com \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=ravi.bangoria@linux.vnet.ibm.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox