Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1194682imm; Fri, 28 Sep 2018 13:49:54 -0700 (PDT) X-Google-Smtp-Source: ACcGV62n175TaeFjyWdNtezytuu5b71rfQxIDcLEStQSAGOuc9oVXx8i9Z/CevVKibnvRdmOuKWf X-Received: by 2002:a17:902:1:: with SMTP id 1-v6mr306315pla.206.1538167794185; Fri, 28 Sep 2018 13:49:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538167794; cv=none; d=google.com; s=arc-20160816; b=RvTjfhFsw/zmtziRabjs2IiIf7/VRVcwxMMJImU6ngk7+LqxU8vFuBFAI4TwvrufwM YpI+o21zds0TQ1tpdLfTQyfr6+A9nQvsab9cDim2jOzZ1ynQXqYE1Eywq1vwfWmcLbG0 m3uBOWxxTt4QDNVgwTdvR9Kyn/IqXayGHhIkIMMRm2861c7P+0/TnnwLeX+GETUTp/eu S6AyGuU0cQBXvTMMKRz0R9Haa/bcbaKlEx5ic3ZFme6mMISIzLez/P4jxzaTz3PCRYPc q2ShBTg7i11EdbhMkDYixPq4BpFqhA5S9//H1xkNHvjFiuiR1mh+zT6tFL1qGGe0NNz9 4x9A== 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; bh=ku1KTxH+xyH1sGCccXg1k/f22CwIxIUbRk8FMjP8jM0=; b=g/zGmqMg76nWck733j/yykpNNlR3v968BO7rnumnU1OZHzUUrJVH+g0CTCNCJaDgJs rElAyDwEndXrgjzQY6Ft8M0M16oLnbbjInfUtmQAL+7udH4ow4Ff35Q23QHsjYp4QrV4 Srt0VBBCBhf+1b3muY4Z4Lyp+agehjVkCfn2jznkO8tUT4q/gk9M5S26WPFFzfyQngRV kW/A3UpUbV6aBhaT1uuScRCbeAV7sX/kByCf4grKZ2q7GoxNpwhfrwfzP6lP5wtl6yb8 i2FYrsvsOZCvs+v4psr7xLhSsi5ZvZr3FuBKfsnMXulc481IYLEjNEH04aw2n9eVyXUg 2/FQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x31-v6si5621453pgk.666.2018.09.28.13.49.39; Fri, 28 Sep 2018 13:49:54 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727269AbeI2DPA (ORCPT + 99 others); Fri, 28 Sep 2018 23:15:00 -0400 Received: from mga14.intel.com ([192.55.52.115]:37881 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726664AbeI2DO7 (ORCPT ); Fri, 28 Sep 2018 23:14:59 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Sep 2018 13:49:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,316,1534834800"; d="scan'208";a="90498389" Received: from tassilo.jf.intel.com (HELO tassilo.localdomain) ([10.7.201.126]) by fmsmga002.fm.intel.com with ESMTP; 28 Sep 2018 13:49:28 -0700 Received: by tassilo.localdomain (Postfix, from userid 1000) id 4749B300B51; Fri, 28 Sep 2018 13:49:30 -0700 (PDT) Date: Fri, 28 Sep 2018 13:49:30 -0700 From: Andi Kleen To: Mark Rutland Cc: Thomas Gleixner , Tvrtko Ursulin , LKML , tvrtko.ursulin@linux.intel.com, Peter Zijlstra , x86@kernel.org, "H. Peter Anvin" , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Madhavan Srinivasan , Alexey Budankov , Kees Cook , Jann Horn Subject: Re: [RFC 0/5] perf: Per PMU access controls (paranoid setting) Message-ID: <20180928204930.GC32651@tassilo.jf.intel.com> References: <20180919122751.12439-1-tvrtko.ursulin@linux.intel.com> <20180928164111.i6nba2j6mnegwslw@lakrids.cambridge.arm.com> <20180928172340.GA32651@tassilo.jf.intel.com> <20180928174016.i7d24puv7y3jwzf6@lakrids.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180928174016.i7d24puv7y3jwzf6@lakrids.cambridge.arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 28, 2018 at 06:40:17PM +0100, Mark Rutland wrote: > On Fri, Sep 28, 2018 at 10:23:40AM -0700, Andi Kleen wrote: > > > There's also been prior discussion on these feature in other contexts > > > (e.g. android expoits resulting from out-of-tree drivers). It would be > > > nice to see those considered. > > > > > > IIRC The conclusion from prior discussions (e.g. [1]) was that we wanted > > > finer granularity of control such that we could limit PMU access to > > > specific users -- e.g. disallow arbitrary android apps from poking *any* > > > PMU, while allowing some more trusted apps/users to uses *some* specific > > > PMUs. > > > > > > e.g. we could add /sys/bus/event_source/devices/${PMU}/device, protect > > > this via the usual fs ACLs, and pass the fd to perf_event_open() > > > somehow. A valid fd would act as a capability, taking precedence over > > > perf_event_paranoid. > > > > That sounds like an orthogonal feature. I don't think the original > > patchkit would need to be hold up for this. It would be something > > in addition. > > I have to say that I disagree -- these controls will have to interact > somehow, and the fewer of them we have, the less complexity we'll have > to deal with longer-term. You're proposing to completely redesign perf_event_open. This new file descriptor argument doesn't exist today so it would need to create a new system call with more arguments (and BTW it would be more than the normal 6 argument limit we have, so actually it couldn't even be a standard sycall) Obviously we would need to keep the old system call around for compability, so you would need to worry about this interaction in any case! So tying it together doesn't make any sense, because the problem has to be solved separately anyways. > > > BTW can't you already do that with the syscall filter? I assume > > the Android sandboxes already use that. Just forbid perf_event_open > > for the apps. > > Note that this was about providing access to *some* PMUs in some cases. > > IIUC, if that can be done today via a syscall filter, the same is true > of per-pmu paranoid settings. The difference is that the Android sandboxes likely already doing this and have all the infrastructure, and it's just another rule. Requiring syscall filters just to use the PMU on xn system that otherwise doesn't need them would be very odd. -Andi