Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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@google.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: <stable@vger.kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.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@kernel.org>

authored by

Yabin Cui and committed by
Ingo Molnar
02e18447 09121255

+4
+4
kernel/events/core.c
··· 5943 5943 unsigned long sp; 5944 5944 unsigned int rem; 5945 5945 u64 dyn_size; 5946 + mm_segment_t fs; 5946 5947 5947 5948 /* 5948 5949 * We dump: ··· 5961 5960 5962 5961 /* Data. */ 5963 5962 sp = perf_user_stack_pointer(regs); 5963 + fs = get_fs(); 5964 + set_fs(USER_DS); 5964 5965 rem = __output_copy_user(handle, (void *) sp, dump_size); 5966 + set_fs(fs); 5965 5967 dyn_size = dump_size - rem; 5966 5968 5967 5969 perf_output_skip(handle, rem);