Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2603038imm; Fri, 24 Aug 2018 02:03:11 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda1xmJ6VAZdvfP7MBUAPDa7OGrWCfuhNQw//0lcfeSxiCt+6N31Lti4dvY25D5vsKTVvMZE X-Received: by 2002:a63:c702:: with SMTP id n2-v6mr850599pgg.108.1535101391349; Fri, 24 Aug 2018 02:03:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535101391; cv=none; d=google.com; s=arc-20160816; b=AHy6xEIG5qjkl2w6mKs/VUetseke098j3880o1nzuS+uXxqqTlAopp1f3CUV5KWygR WKbm0dylvMxcaYtmvGw5lg2vY8ukiklftuuUxkSAf0I3K/qEQfWM2+vB2evH5Sx4Iqrs WAp+bdjHXGmtIvLTIYyYKQ58lBMU6VQc2u4nTMtJqhrAYpk9xUW9T6rdG+y9TXH+kFBy Me7rdoWGqE6n6ZyKPcC9IMncuMnZsSrdTXYejb2XUFEduTXbIzJYSNgXDseM4yMZiVNF KiyfsUwK02dNrtrDFtdmsI20N9Wr3ednu5BQDwEZ+fwZWozalRFJXv1N0eo3dKommyIj XIsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=6+OUCC7RnGRXvLq3d7cG1dIVzq3dw6UiWQI3xhlpWNc=; b=VJ2DRYj8t+R7XbO90QT8h9CUrtqnfTW1DpblK0bPDGtrZO7Pfp52GF6Hqa4BX054g6 iZEfLAMbiO3xZjuuWTxzP4mv0wECIXt6EX9CMVXw1y0i5mhOjGJB0APGZTAqx/v5tdcb jFWnx/lVPHqUTP1TKnHphHiWWzfyBQom8NtYfjR2U5V7VKDQfYUCoa9xCXtzZzWWmWFF omTKktdWdHEEX67jSo+qczhawWkekb8cCA2+yXDfEfv6l+6JChWdvxGbPUp0i/uUyrZo 0ny0y6BQ+nJUOmJ1fQioZo21HTD2qYG+cvkRgLQYkLeXNlZarUjqqW5Z3PmpNxDhxkFX t1bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=iBdyqmMU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q61-v6si6294246plb.231.2018.08.24.02.02.55; Fri, 24 Aug 2018 02:03:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=iBdyqmMU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727414AbeHXMfY (ORCPT + 99 others); Fri, 24 Aug 2018 08:35:24 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:36062 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726768AbeHXMfY (ORCPT ); Fri, 24 Aug 2018 08:35:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=6+OUCC7RnGRXvLq3d7cG1dIVzq3dw6UiWQI3xhlpWNc=; b=iBdyqmMUhjco1hqMTPRgavbaJ RKQtL2QJj9Wj0KgLbYfXqMd305qvgUNemHiBYzHQ2pujrVPMdLKYHx1wtLKIdJOmAjswce6pmlWiH RQtAgMq/vy5pgEWzP8z2Sqw31Xoq4SY/neKMAWoyxixkTblZplpt5gktUrBR21qPSS9rE5r+tB+Hr AZTZWi2Zr4InXd7zeThdReyC1h2q0UvBv7CeC5Er625noyGRSiHWHTS4Z7vJ3pqmECnzwr6mTV1/H UrzvOETSFz/5/MNV9PpZMqfJEoQv5SY3t3bQtV1ld5OCcfEzlJwGjG2fOXbKT2nnRKcnPSEl+1p4e zanzcUMIQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1ft7t3-0004mM-B2; Fri, 24 Aug 2018 08:57:47 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 1D30D202E65E0; Fri, 24 Aug 2018 10:56:01 +0200 (CEST) Date: Fri, 24 Aug 2018 10:56:01 +0200 From: Peter Zijlstra To: Yabin Cui Cc: Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org Subject: Re: [PATCH] perf: Force USER_DS when recording user stack data. Message-ID: <20180824085601.GM24124@hirez.programming.kicks-ass.net> References: <20180823225935.27035-1-yabinc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180823225935.27035-1-yabinc@google.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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) > --- > 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 >