lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180824085601.GM24124@hirez.programming.kicks-ass.net>
Date:   Fri, 24 Aug 2018 10:56:01 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Yabin Cui <yabinc@...gle.com>
Cc:     Ingo Molnar <mingo@...hat.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] perf: Force USER_DS when recording user stack data.

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@...gle.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@...radead.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
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ