Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1069904imm; Fri, 28 Sep 2018 11:22:50 -0700 (PDT) X-Google-Smtp-Source: ACcGV63LajPBbz9YyuEl04Df4+vqechjLrliQdp0HzHFrExURk/zAGvsz8607oZRIVHpy+ahNXiR X-Received: by 2002:a63:a309:: with SMTP id s9-v6mr16293516pge.106.1538158970919; Fri, 28 Sep 2018 11:22:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538158970; cv=none; d=google.com; s=arc-20160816; b=zmVkIbW5tdkMSHEdkvXD/9FboqE9zILtOrheZzrbAY6QhpsW/T7lJiTpM5wn0UE9T2 jFMf81ypciJfadXIbQToftkWp7NwLh1DJfk0sU9q/mxSWG3KbN2aga3YDjaZP9bydQ0m 6yd9PtUZviF3bdm01m7k6JU+6SwFrHa5ahghRCTITf3BWCTlPtO+a0wcbCDG3+7kZIzj dhjdGmT5lVGnnVxazam5uVYE7NafKODUOPEw0WTj9f92dCaZxrdLDWSs7V3Kuds4z4mK 4sPU5L7EcvtSsu/a9f/ipMoqLkBg85XZeQzndaoVhCUCwVSnO11fUZubr8uHx5+Z0MHN 9rrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=Rhfc4m3F+IJELkxn90xLpUa8NL2+jfwFO+T2EdvfXeU=; b=BmMeeqKHAoNBcYlI9kLkNx2lvHhwb6bP4RdGvyeBesqqrMMGuMoxKx5TAU7FC2zKUz l9u1gpH2eBlli64sIv16Cevw9GYb4cMiga34Uk/wb3qSuU1wbq6H2w5FVug6kJHfm4iM PrqEz5X91qQNL7iYTfR212oczVvIAXNiwXqFSlqxOo0Dppr0rd+MhZuFU2uNq4kaWbzu VSRCRs2ExI63U1JaPEIzuCrAyWHPoaFMjlN/6JOx0S8nqkGpdIXs/yozXj51vRMlEocK XdtlFEx5K9COL+bJL2BipAaLfPtgIw7w74O53RDqtRL1Nw7heiyByhlrz+skJGZZD6RV cUUQ== ARC-Authentication-Results: i=1; mx.google.com; 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 33-v6si5681829plv.241.2018.09.28.11.22.36; Fri, 28 Sep 2018 11:22:50 -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; 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 S1726755AbeI2Apd (ORCPT + 99 others); Fri, 28 Sep 2018 20:45:33 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:54973 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725906AbeI2Apd (ORCPT ); Fri, 28 Sep 2018 20:45:33 -0400 Received: from p5492e4c1.dip0.t-ipconnect.de ([84.146.228.193] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1g5xNN-0003pi-Im; Fri, 28 Sep 2018 20:20:29 +0200 Date: Fri, 28 Sep 2018 20:20:28 +0200 (CEST) From: Thomas Gleixner To: Alexey Budankov cc: Tvrtko Ursulin , Kees Cook , Jann Horn , Tvrtko Ursulin , LKML , Peter Zijlstra , x86@kernel.org, "H. Peter Anvin" , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Madhavan Srinivasan , Andi Kleen Subject: Re: [RFC 0/5] perf: Per PMU access controls (paranoid setting) In-Reply-To: <0feb9867-0040-0306-a95b-4b6df1818312@linux.intel.com> Message-ID: References: <20180919122751.12439-1-tvrtko.ursulin@linux.intel.com> <0feb9867-0040-0306-a95b-4b6df1818312@linux.intel.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Alexey, On Fri, 28 Sep 2018, Alexey Budankov wrote: > On 28.09.2018 17:02, Thomas Gleixner wrote: > > But this does also require a proper analysis and documentation why it is > > not a security risk to expose the i915 PMU or what potential security > > issues this can create, so that the competent sysadmin can make a > > judgement. > > > > And the same is required for all other PMUs which can be enabled in the > > same way for unprivileged access. And we might as well come to the > > conclusion via analysis that for some PMUs unpriviledged access is just not > > a good idea and exclude them. I surely know a few which qualify for > > exclusion, so the right approach is to provide this knob only when the risk > > is analyzed and documented and the PMU has been flagged as candidate for > > unpriviledged exposure. I.e. opt in and not opt out. > > If you ask me then, IMHO, unprivileged access to CBOX pmu looks unsafe > and is now governed by traditional *core* perf_event_paranoid setting. > > But *core* paranoid >= 1 (per-process mode) prevents simultaneous perf > record sampling and perf stat -I reading from IMC, UPI, PCIe and other > uncore counters. > > This kind of monitoring could make process performance observability > thru Perf subsystem more flexible and better tailored for cloud and > cluster environments. However it requires fine-tuning control > capabilities in order to still keep system as secure as possible. > > Could i915, IMC, UPI, PCIe pmus be safe enough to be governed by > a separate perf_event_paranoid settings? Just to make it clear. I'm not against separate settings at all. But I'm against adding knobs for every PMU the kernel supports wholesale without analysis and documentation just because we can and somebody wants it. Right now we have a single knob, which is poorly documented and that should be fixed first. But some googling gives you the information that allowing unprivilegded access is a security risk. So the security focussed sysadmin will deny access to the PMUs no matter what. Now we add more knobs without documentation what the exposure and risk of each PMU is. The proposed patch set does this wholesale for every PMU supported by the kernel. So the GPU user will ask the sysadmin to allow him access. How can he make an informed decision? If he grants it then the next user comes around and wants it for something else arguing that the other got it for the GPU already. How can he make an informed decision about that one? We provide the knobs, so it's also our responsibility towards our users to give them the information about their usage and scope. And every single PMU knob has a different scope. The documentation of the gazillion of knobs in /proc and /sysfs is not really brilliant, but we should really not continue this bad practice especially not when these knobs have potentially security relevant implcations. Yes, I know, writing documentation is work, but it's valuable and is appreciated by our users. To make this doable and not blocked by requiring every PMU to be analyzed and documented at once, I suggested to make this opt-in. Do analysis for a given PMU, decide whether it should be exposed at all. If so, document it proper and flip the bit. That way this can be done gradually as the need arises and we can exclude the riskier ones completely. I don't think this is an unreasonable request as it does not require the i915 folks to look at PMUs they are not familiar with and does not get blocked by waiting on every PMU wizard on the planet to have time. Start with something like Documentation/admin-guide/perf-security.rst or whatever name fits better and add a proper documentation for the existing knob. With the infrastructure for fine grained access control add the general explanation for fine grained access control. With each PMU which opt's in for the knob, add a section with guidance about scope and risk for this particular one. Thanks, tglx