From: Peter Zijlstra <peterz@infradead.org>
To: Yabin Cui <yabinc@google.com>
Cc: Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf: Force USER_DS when recording user stack data.
Date: Fri, 24 Aug 2018 10:56:01 +0200 [thread overview]
Message-ID: <20180824085601.GM24124@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20180823225935.27035-1-yabinc@google.com>
On Thu, Aug 23, 2018 at 03:59:35PM -0700, Yabin Cui wrote:
> 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@google.com>
Ingo, I think this wants a stable tag too; seems to be a corrolary of:
88b0193d9418 ("perf/callchain: Force USER_DS when invoking perf_callchain_user()")
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> kernel/events/core.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 2a62b96600ad..9bc047421e75 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -5948,6 +5948,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:
> @@ -5965,7 +5966,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);
> --
> 2.19.0.rc0.228.g281dcd1b4d0-goog
>
next prev parent reply other threads:[~2018-08-24 9:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-23 22:59 [PATCH] perf: Force USER_DS when recording user stack data Yabin Cui
2018-08-24 8:56 ` Peter Zijlstra [this message]
2018-09-10 12:39 ` [tip:perf/urgent] perf/core: " tip-bot for Yabin Cui
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=20180824085601.GM24124@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=yabinc@google.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;
as well as URLs for NNTP newsgroup(s).