[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <tip-02e184476eff848273826c1d6617bb37e5bcc7ad@git.kernel.org>
Date: Mon, 10 Sep 2018 05:39:39 -0700
From: tip-bot for Yabin Cui <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: torvalds@...ux-foundation.org, hpa@...or.com,
stable@...r.kernel.org, yabinc@...gle.com, peterz@...radead.org,
linux-kernel@...r.kernel.org, namhyung@...nel.org,
tglx@...utronix.de, jolsa@...hat.com,
alexander.shishkin@...ux.intel.com, mingo@...nel.org,
acme@...nel.org
Subject: [tip:perf/urgent] perf/core: Force USER_DS when recording user
stack data
Commit-ID: 02e184476eff848273826c1d6617bb37e5bcc7ad
Gitweb: https://git.kernel.org/tip/02e184476eff848273826c1d6617bb37e5bcc7ad
Author: Yabin Cui <yabinc@...gle.com>
AuthorDate: Thu, 23 Aug 2018 15:59:35 -0700
Committer: Ingo Molnar <mingo@...nel.org>
CommitDate: Mon, 10 Sep 2018 14:01:46 +0200
perf/core: Force USER_DS when recording user stack data
Perf can record user stack data in response to a synchronous request, such
as a tracepoint firing. If this happens under set_fs(KERNEL_DS), then we
end up reading user stack data using __copy_from_user_inatomic() under
set_fs(KERNEL_DS). I think this conflicts with the intention of using
set_fs(KERNEL_DS). And it is explicitly forbidden by hardware on ARM64
when both CONFIG_ARM64_UAO and CONFIG_ARM64_PAN are used.
So fix this by forcing USER_DS when recording user stack data.
Signed-off-by: Yabin Cui <yabinc@...gle.com>
Acked-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Cc: <stable@...r.kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: Jiri Olsa <jolsa@...hat.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Fixes: 88b0193d9418 ("perf/callchain: Force USER_DS when invoking perf_callchain_user()")
Link: http://lkml.kernel.org/r/20180823225935.27035-1-yabinc@google.com
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
kernel/events/core.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index abaed4f8bb7f..c80549bf82c6 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -5943,6 +5943,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
unsigned long sp;
unsigned int rem;
u64 dyn_size;
+ mm_segment_t fs;
/*
* We dump:
@@ -5960,7 +5961,10 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
/* Data. */
sp = perf_user_stack_pointer(regs);
+ fs = get_fs();
+ set_fs(USER_DS);
rem = __output_copy_user(handle, (void *) sp, dump_size);
+ set_fs(fs);
dyn_size = dump_size - rem;
perf_output_skip(handle, rem);
Powered by blists - more mailing lists