Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp510246ybl; Wed, 11 Dec 2019 03:14:57 -0800 (PST) X-Google-Smtp-Source: APXvYqyCsuizVnlWR5ofBdLO+5Fx0Oa6pcJ3HLZQS/D5FSWFLp+d2I8zS7T8/6xahCrfsiXiUcT+ X-Received: by 2002:a05:6830:114f:: with SMTP id x15mr1753626otq.291.1576062897515; Wed, 11 Dec 2019 03:14:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576062897; cv=none; d=google.com; s=arc-20160816; b=M8D7M7Om+bMFI33QNz2f2ShSHeIHza7FZEtPqhxNXvyAxe5JWtKgX4/blu9qFAwKDs dHL2VY/Y3qKwzL3gEHWuj2xJ9XOvAHO7Yl+2uQr08hpY9RFdIKPopWe7ctEX+O7kXGLL ZeJodvF0SP/l0fF+aJMO7kMpK+4hUA6dbjYs23T/qIQaN6kvtHKWVUmhxQpEKurG7DWJ TGohNuGAB9S2hhu53YAOB0mR2C1VFPwnOyqFWA07J7lIBv9Mt7VEMQjA/Yew7JK9JqcB bDUbRkfWctF+RGXonwb+kmowcNFDK7Ssp1uKpy9WA4gs/aur+m2zSr5m6SHWWxQ8GljL oURQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:references:cc:to:subject:from; bh=hOx2+lTHLoJgopAk9+MftOzVhdCP/ijndSLTSJHZVzk=; b=UgnCCqxKkyCulwrzG4ORpND+KSFzFp+MXnWwqf0/BOndDvPZ9GIOZVXc82xjBh5WvP Qk9HsQ2532n5FGuwzwMftRklYI+/OEgy5TvMn6NlTFe8HPQ8jDKgGfhW2cBLsDDC/P59 eNxx/paeLz9uDJ1gPd9K0bW5xI7SO585TSQgeRo/DcGIGpzyaxGZa+iI4tcCx7I7BLqg l6EXL2zf+oCDSnOCl7TVvMfE/et/jhN22GP6dA7yNwvtyD87jA4T5MNVp0TWotN68bZ0 9Pvg9ijOznnLX5k9bVQU9ZaiEQRNBihPHb22UKKYvEbG1lMuf4DORqei5RQS34FuNNMO wANg== 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 m82si926924oig.129.2019.12.11.03.14.45; Wed, 11 Dec 2019 03:14:57 -0800 (PST) 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 S1728446AbfLKLMl (ORCPT + 99 others); Wed, 11 Dec 2019 06:12:41 -0500 Received: from mga09.intel.com ([134.134.136.24]:22038 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727469AbfLKLMl (ORCPT ); Wed, 11 Dec 2019 06:12:41 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Dec 2019 02:52:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,301,1571727600"; d="scan'208";a="215736932" Received: from linux.intel.com ([10.54.29.200]) by orsmga006.jf.intel.com with ESMTP; 11 Dec 2019 02:52:20 -0800 Received: from [10.125.252.248] (abudanko-mobl.ccr.corp.intel.com [10.125.252.248]) by linux.intel.com (Postfix) with ESMTP id 143BF580297; Wed, 11 Dec 2019 02:52:16 -0800 (PST) From: Alexey Budankov Subject: Re: [PATCH v1 0/3] Introduce CAP_SYS_PERFMON capability for secure Perf users groups To: Casey Schaufler , Peter Zijlstra , Arnaldo Carvalho de Melo , Ingo Molnar Cc: Jiri Olsa , Andi Kleen , elena.reshetova@intel.com, Alexander Shishkin , Jann Horn , Kees Cook , Stephane Eranian , Namhyung Kim , linux-security-module@vger.kernel.org, selinux@vger.kernel.org, linux-kernel References: <283f09a5-33bd-eac3-bdfd-83d775045bf9@linux.intel.com> <1e836f34-eda3-542d-f7ce-9a3e87ac5e2e@schaufler-ca.com> Organization: Intel Corp. Message-ID: Date: Wed, 11 Dec 2019 13:52:15 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05.12.2019 20:33, Casey Schaufler wrote: > On 12/5/2019 9:05 AM, Alexey Budankov wrote: >> Hello Casey, >> >> On 05.12.2019 19:49, Casey Schaufler wrote: >>> On 12/5/2019 8:15 AM, Alexey Budankov wrote: >>>> Currently access to perf_events functionality [1] beyond the scope permitted >>>> by perf_event_paranoid [1] kernel setting is allowed to a privileged process >>>> [2] with CAP_SYS_ADMIN capability enabled in the process effective set [3]. >>>> >>>> This patch set introduces CAP_SYS_PERFMON capability devoted to secure performance >>>> monitoring activity so that CAP_SYS_PERFMON would assist CAP_SYS_ADMIN in its >>>> governing role for perf_events based performance monitoring of a system. >>>> >>>> CAP_SYS_PERFMON aims to harden system security and integrity when monitoring >>>> performance using perf_events subsystem by processes and Perf privileged users >>>> [2], thus decreasing attack surface that is available to CAP_SYS_ADMIN >>>> privileged processes [3]. >>> Are there use cases where you would need CAP_SYS_PERFMON where you >>> would not also need CAP_SYS_ADMIN? If you separate a new capability >> Actually, there are. Perf tool that has record, stat and top modes could run with >> CAP_SYS_PERFMON capability as mentioned below and provide system wide performance >> data. Currently for that to work the tool needs to be granted with CAP_SYS_ADMIN. > > The question isn't whether the tool could use the capability, it's whether > the tool would also need CAP_SYS_ADMIN to be useful. Are there existing > tools that could stop using CAP_SYS_ADMIN in favor of CAP_SYS_PERFMON? > My bet is that any tool that does performance monitoring is going to need > CAP_SYS_ADMIN for other reasons. > >> >>> from CAP_SYS_ADMIN but always have to use CAP_SYS_ADMIN in conjunction >>> with the new capability it is all rather pointless. >>> >>> The scope you've defined for this CAP_SYS_PERFMON is very small. >>> Is there a larger set of privilege checks that might be applicable >>> for it? >> CAP_SYS_PERFMON could be applied broadly, though, this patch set enables record >> and stat mode use cases for system wide performance monitoring in kernel and >> user modes. > > The granularity of capabilities is something we have to watch > very carefully. Sure, CAP_SYS_ADMIN covers a lot of things, but > if we broke it up "properly" we'd have hundreds of capabilities. Fully agree and this broader discussion is really helpful to come up with properly balanced solution. > If you want control that finely we have SELinux. Undoubtedly, SELinux is the powerful, mature, whole level of functionality that could provide benefits not only for perf_events subsystem. However perf_events is built around capabilities to provide access control to its functionality, thus perf_events would require considerable rework prior it could be controlled thru SELinux. Then the adoption could also require changes to the installed infrastructure just for the sake of adopting alternative access control mechanism. On the other hand there are currently already existing users and use cases that are built around the CAP_SYS_ADMIN based access control, and Perf tool, which is the native Linux kernel observability and performance profiling tool, provides means to operate in restricted multiuser environments(HPC clusters, cloud and virtual environments) for groups of unprivileged users under admins control [1]. In this circumstances CAP_SYS_PERFMON looks like smart balanced advancement that trade-offs between perf_events subsystem extensions, required level of control and configurability of perf_events, existing users adoption effort, and it brings security hardening benefits of decreasing attack surface for the existing users and use cases. Well, yes, it is really good that Linux nowadays provides a handful of various security assuring mechanisms but proper balance is what usually makes valuable features happen and its users happy and moves forward. Gratefully, Alexey [1] https://www.kernel.org/doc/html/latest/admin-guide/perf-security.html