Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1524702imm; Tue, 22 May 2018 05:32:56 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpv3YeCX7t1fpNqCAzeeXpHG3ME2byeusr5HiizLBmfDSpc+MJHoHdLEEiksuuk+e/Twl9d X-Received: by 2002:a63:2783:: with SMTP id n125-v6mr18632714pgn.377.1526992376243; Tue, 22 May 2018 05:32:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526992376; cv=none; d=google.com; s=arc-20160816; b=uFCScpj6bBHb3gTiN5uLXNNgvs67QxMkr69z5P7RFcDhWE+Kd30P30k5BZVVx2cQ4k GOLS1v2cP2tGifeIvD/z3soDeaPWo7TvFL5VnjRK0LRNl9pNQBVptSpXoLl+N5SBWcXh bWB/qeGZl8uLkbGmfiVT+UE73Nk5X3YpjAcEXVKxG9dAhSXknd8D5cMUeqGh/WANddwo Z5TYUGwHnotIeFUp23Qt3oiKk6PuUq4PJFOeQmYMYmoFNK5ObsHTQ/pKDxOa3UwVAQZa nOeLEe/nnbJ2HDaN/9MZCJnGVTR7+wbBrwlSz1BCSQZT5zCIvKHjPSwKIv1OkKXCX/tL SMxw== 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=CMssF25EyGMpDZiCdLlrVJPOKaOXDhYCQcig++56zJg=; b=uwlUVdMdVKXDOIgWSKPX8uqe/1lq2B5nVcKDCGN7uEHI6H61gaddTJyrRDd5y08H5K +yByneWyprTIDrozsnT6xQZZpVBZRNxmo80VV+m5s2swFtge5hGl1jbMWk55tBhjMizn 5wOEwF7sOdIYRktLerzkg6DfCL//XxXSSeg2oUYfw2rRlcF9myHaVYgH0dnIYdI6THBK SySDKobvnyzN+R6IZZFjnTIL6Kp6wAsxAPrIaxFlx6uZddbESDcZkjnTSn7F7rdzJ0N8 m3w2WVbBGKRyy9y49QB8dNhVJq6cjuPuP5+7Nf2srFVx3VowJ2utSSCt0w6pXj+tKp9h a8uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=UJiB7W7u; 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 g187-v6si12829571pgc.644.2018.05.22.05.32.41; Tue, 22 May 2018 05:32:56 -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=UJiB7W7u; 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 S1751499AbeEVMcX (ORCPT + 99 others); Tue, 22 May 2018 08:32:23 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:37470 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751192AbeEVMcU (ORCPT ); Tue, 22 May 2018 08:32:20 -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=CMssF25EyGMpDZiCdLlrVJPOKaOXDhYCQcig++56zJg=; b=UJiB7W7uDJfELUyUIBTOSYFP4 SVz9Z5/88f0eul8A8RRTdXsOCfnTU8ReB7q5cpGx5qirfip8/eCJRswWQ2pBVJIqh6ebhM4kgVohR n5/8YSaNfLJ9JK0FWA8w7fbPVm4VDw+x0Q5rnO8TetVBO3kojeIZEU3rjtvk2aGQ9TpLUiD2Psilh 3R7pVqw1xQFc8dAojodGgj8omG9h7hZaXXFiosEOYuchCZmDt38iPVPhxgZju93Ti4WC+YzfAYKhd SbawanSRxpZxWwY0gRxSuNBLgPZmxSYVprUcRpZmQJY74D04IIXuZpQEDdZBhxdG5XPInGlGwumFY jqgLApNvg==; 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 1fL6Sd-0004PN-Gz; Tue, 22 May 2018 12:32:15 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 655252029F870; Tue, 22 May 2018 14:32:13 +0200 (CEST) Date: Tue, 22 May 2018 14:32:13 +0200 From: Peter Zijlstra To: Tvrtko Ursulin Cc: linux-kernel@vger.kernel.org, Tvrtko Ursulin , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Mark Rutland , Tvrtko Ursulin Subject: Re: [RFC] perf: Allow fine-grained PMU access control Message-ID: <20180522123213.GR12198@hirez.programming.kicks-ass.net> References: <20180521092549.5349-1-tvrtko.ursulin@linux.intel.com> <20180522090527.GP12198@hirez.programming.kicks-ass.net> <017c4a20-b597-9c0e-4cf3-c0fd1d7bf3d7@ursulin.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <017c4a20-b597-9c0e-4cf3-c0fd1d7bf3d7@ursulin.net> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 22, 2018 at 10:29:29AM +0100, Tvrtko Ursulin wrote: > > On 22/05/18 10:05, Peter Zijlstra wrote: > > On Mon, May 21, 2018 at 10:25:49AM +0100, Tvrtko Ursulin wrote: > > > From: Tvrtko Ursulin > > > > > > For situations where sysadmins might want to allow different level of > > > of access control for different PMUs, we start creating per-PMU > > > perf_event_paranoid controls in sysfs. > > > > Could you explain how exactly this makes sense? > > > > For example, how does it make sense for one PMU to reveal kernel data > > while another PMU is not allowed. > > > > Once you allow one PMU to do so, the secret is out. > > > > So please explain, in excruciating detail, how you want to use this and > > how exactly that makes sense from a security pov. > > Not sure it will be excruciating but will try to explain once again. > > There are two things: > > 1. i915 PMU which exports data such as different engine busyness levels. > (Perhaps you remember, you helped us implement this from the perf API > angle.) Right, but I completely forgot everything again.. So thanks for reminding. > 2. Customers who want to look at those stats in production. > > They want to use it to answer questions such as: > > a) How loaded is my server and can it take one more of X type of job? > b) What is the least utilised video engine to submit the next packet of work > to? > c) What is the least utilised server to schedule the next transcoding job > on? On the other hand, do those counters provide enough information for a side-channel (timing) attack on GPGPU workloads? Because, as you say, it is a shared resource. So if user A is doing GPGPU crypto, and user B is observing, might he infer things from the counters? > Current option for them is to turn off the global paranoid setting which > then enables unprivileged access to _all_ PMU providers. Right. > To me it sounded quite logical that it would be better for the paranoid knob > to be more fine-grained, so that they can configure their servers so only > access to needed data is possible. The proposed semantics are a tad awkward though, the moment you prod at the sysctl you loose all individual PMU settings. Ideally the per-pmu would have a special setting that says follow-global in addition to the existing ones. > I am not sure what do you mean by "Once you allow one PMU to do so, the > secret is out."? What secret? Are you implying that enabling unprivileged > access to i915 engine busyness data opens up access to CPU PMU's as well via > some side channel? It was not i915 specific; but if you look at the descriptions: * perf event paranoia level: * -1 - not paranoid at all * 0 - disallow raw tracepoint access for unpriv * 1 - disallow cpu events for unpriv * 2 - disallow kernel profiling for unpriv Then the moment you allow some data to escape, it cannot be put back. i915 is fairly special in that (afaict) it doesn't leak kernel specific data In general I think allowing access to uncore PMUs will leak kernel data. Thus in general I'm fairly wary of all this. Is there no other way to expose this information? Can't we do a traditional load-avg like thing for the GPU?