Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp959976ybl; Wed, 11 Dec 2019 10:10:26 -0800 (PST) X-Google-Smtp-Source: APXvYqyZK3u/19//7/9q/WfGNALvAmoFeapEmzPgoJw8zbdfrbyeaYnnDRPY/3CzenDGLhEJPe0I X-Received: by 2002:a9d:7590:: with SMTP id s16mr3046050otk.89.1576087826463; Wed, 11 Dec 2019 10:10:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576087826; cv=none; d=google.com; s=arc-20160816; b=XjmqOOMZ63IYUUaupt/wzoJPdeoLPcpclXb8JCd/PLjWPoxL87p42O9hQWFyTUCfvW g/X1QG2KOxXIrm9Igd+fDsUeeRnQQ74o8YDvC6p96UanQE6jT647kCd+SCv0qWhKwh+I zVm9FgMBPvq12STMEYINokh1FpEu3w2xsUl4kG9cD6EXt7Eh6ItiNLjBRsqlHiv9/S2L ugeV3oTsIn2+OPhUAfyXhMtZ+4DiGDkRHGQ4q4w7JGsrmB8nEw/5Boz9hVxOpisLOwTe vsD2/TyjtwxBtcXNnMZ/wZuy46ifZju6W2A+KMt9IbnnddFQ6LxiPIdUTBd7JbqZVecr 0PAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :dkim-signature; bh=viEowQiKvjFND68sR3c3UpyOmWS0jjunhPLnDvcY6M4=; b=cskuBLCoNP8oZrmVJwrsc+7ATF36EHbBIQzpUix8Ec9wr+sty7MFF5shoJEFEg+WKn T6MsrxpeaEsa7NIMhGfpZNLAvbnv58vzsvxVEXnA7zgIor8z2vlHUhAarawBl+Y2oji3 V8jKYW7r61NKHCjTzKJw5kMd2UxBfHQZykb3Zv4a8Kn9OfVZRAOSvpxaWwoj0JjrGc1R 5HdiHB5LPEHRYTPbJIn3PGiQ0OgsVBkvokBTcMvj6iyw2n74h1nvRiF7GHxhFW3u3dC5 rgG7MOFLyROfv/brlqRs6JL4gb8ME22CSzhiD1/l4xdqaU6x3ehyceX1o6DoAHKpgPhT 1oWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=WD1KBhIz; 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 w5si1667407otq.238.2019.12.11.10.10.12; Wed, 11 Dec 2019 10:10:26 -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; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=WD1KBhIz; 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 S1730924AbfLKSJk (ORCPT + 99 others); Wed, 11 Dec 2019 13:09:40 -0500 Received: from sonic313-15.consmr.mail.ne1.yahoo.com ([66.163.185.38]:44685 "EHLO sonic313-15.consmr.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730876AbfLKSJh (ORCPT ); Wed, 11 Dec 2019 13:09:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1576087776; bh=viEowQiKvjFND68sR3c3UpyOmWS0jjunhPLnDvcY6M4=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=WD1KBhIzXiRxcEPjUe9IwVNWcyW9d2flD2Txsj/QkZDd8zVYJipnTTXJkVRuV610oC75JrcuhrqPJlspYND3Dy/Jrb27M1EDORqavOOpr5OQ5IF7NNl3Qx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QhVmXdZQHaKBgWkOFx80NNwoFfCUfd7gqRI1KexRTW3tP_5LLpFFdFaO76j0CFjzhOPI 4FasepunqXrpPTLXNiguEFI6ZN3u8ASTVCbVbvzQ4JhYNzWMr4sZjCH.fpaFcMVLr26vwOTE7cdp 1V6cXKreVLB8EnSvtI_Db_kqkN6pOlz_oV8_tpt8THmG.4XsOaFZDi5Nt7ECHp07SU1exrZfq512 vYKIENYqWy6PyFRJply7uxuTclxBl1nIJY8cTMeHvCAHGiR76yxul0YuEE71W9x.DzP.DrAni_I8 UqamTVJs_NAxBeT4FwriNvTeugytH0i8bBv5zTyquFkS0_WWEbrNKx2BZYeqHgNT2ZmXHB0NRgx9 E0.ikmvclco6su5oMn._qh8UKjgvoNYbCGUgPHOvWqb6UUbB8KejFDF0kf3lF7Jy4i2XYdDUwUu4 sDxI_hWRIWf7kde09AtQ05p1x4rNau6wft5BCfyDYkfyjE5Tq_.r9otU5eQN4udzxCKHmU93Hi_K KV4UhEQKdvNtAXBiwuxfn5Y4DjzG88KxhQ_0Dlu.NKiJEgNsv8TQVyYdq36eP806gp_bH8UclFgc pxqFlMObdXiPdHh3Hy7RCHsV1uVwcOS28NlnR Received: from sonic.gate.mail.ne1.yahoo.com by sonic313.consmr.mail.ne1.yahoo.com with HTTP; Wed, 11 Dec 2019 18:09:36 +0000 Received: by smtp423.mail.bf1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID cd2b57daaca91078fd7aa46e455916da; Wed, 11 Dec 2019 18:09:33 +0000 (UTC) Subject: Re: [PATCH v1 0/3] Introduce CAP_SYS_PERFMON capability for secure Perf users groups To: Alexey Budankov , 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 , Casey Schaufler References: <283f09a5-33bd-eac3-bdfd-83d775045bf9@linux.intel.com> <1e836f34-eda3-542d-f7ce-9a3e87ac5e2e@schaufler-ca.com> From: Casey Schaufler Openpgp: preference=signencrypt Autocrypt: addr=casey@schaufler-ca.com; keydata= mQINBFzV9HABEAC/mmv3jeJyF7lR7QhILYg1+PeBLIMZv7KCzBSc/4ZZipoWdmr77Lel/RxQ 1PrNx0UaM5r6Hj9lJmJ9eg4s/TUBSP67mTx+tsZ1RhG78/WFf9aBe8MSXxY5cu7IUwo0J/CG vdSqACKyYPV5eoTJmnMxalu8/oVUHyPnKF3eMGgE0mKOFBUMsb2pLS/enE4QyxhcZ26jeeS6 3BaqDl1aTXGowM5BHyn7s9LEU38x/y2ffdqBjd3au2YOlvZ+XUkzoclSVfSR29bomZVVyhMB h1jTmX4Ac9QjpwsxihT8KNGvOM5CeCjQyWcW/g8LfWTzOVF9lzbx6IfEZDDoDem4+ZiPsAXC SWKBKil3npdbgb8MARPes2DpuhVm8yfkJEQQmuLYv8GPiJbwHQVLZGQAPBZSAc7IidD2zbf9 XAw1/SJGe1poxOMfuSBsfKxv9ba2i8hUR+PH7gWwkMQaQ97B1yXYxVEkpG8Y4MfE5Vd3bjJU kvQ/tOBUCw5zwyIRC9+7zr1zYi/3hk+OG8OryZ5kpILBNCo+aePeAJ44znrySarUqS69tuXd a3lMPHUJJpUpIwSKQ5UuYYkWlWwENEWSefpakFAIwY4YIBkzoJ/t+XJHE1HTaJnRk6SWpeDf CreF3+LouP4njyeLEjVIMzaEpwROsw++BX5i5vTXJB+4UApTAQARAQABtChDYXNleSBTY2hh dWZsZXIgPGNhc2V5QHNjaGF1Zmxlci1jYS5jb20+iQJUBBMBCAA+FiEEC+9tH1YyUwIQzUIe OKUVfIxDyBEFAlzV9HACGwMFCRLMAwAFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQOKUV fIxDyBG6ag/6AiRl8yof47YOEVHlrmewbpnlBTaYNfJ5cZflNRKRX6t4bp1B2YV1whlDTpiL vNOwFkh+ZE0eI5M4x8Gw2O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:09:30 -0800 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-Transfer-Encoding: quoted-printable Content-Language: en-US X-Mailer: WebService/1.1.14728 hermes Apache-HttpAsyncClient/4.1.4 (Java/1.8.0_181) Content-Length: 4614 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/11/2019 2:52 AM, Alexey Budankov wrote: > On 05.12.2019 20:33, Casey Schaufler wrote: >> On 12/5/2019 9:05 AM, Alexey Budankov wrote: >>> Hello Casey, >>> =20 >>> 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 privilege= d process >>>>> [2] with CAP_SYS_ADMIN capability enabled in the process effective = set [3]. >>>>> >>>>> This patch set introduces CAP_SYS_PERFMON capability devoted to sec= ure performance >>>>> monitoring activity so that CAP_SYS_PERFMON would assist CAP_SYS_AD= MIN in its >>>>> governing role for perf_events based performance monitoring of a sy= stem. >>>>> >>>>> CAP_SYS_PERFMON aims to harden system security and integrity when m= onitoring >>>>> performance using perf_events subsystem by processes and Perf privi= leged users >>>>> [2], thus decreasing attack surface that is available to CAP_SYS_AD= MIN >>>>> 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 co= uld 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 CA= P_SYS_ADMIN. >> The question isn't whether the tool could use the capability, it's whe= ther >> the tool would also need CAP_SYS_ADMIN to be useful. Are there existin= g >> 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 n= eed >> CAP_SYS_ADMIN for other reasons. >> >>>> from CAP_SYS_ADMIN but always have to use CAP_SYS_ADMIN in conjuncti= on >>>> 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 enab= les record >>> and stat mode use cases for system wide performance monitoring in ker= nel 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 wi= th > properly balanced solution. > >> If you want control that finely we have SELinux. > Undoubtedly, SELinux is the powerful, mature, whole level of functional= ity that > could provide benefits not only for perf_events subsystem. However perf= _events > is built around capabilities to provide access control to its functiona= lity, > thus perf_events would require considerable rework prior it could be co= ntrolled > thru SELinux. Then the adoption could also require changes to the insta= lled > infrastructure just for the sake of adopting alternative access control= mechanism. > > On the other hand there are currently already existing users and use ca= ses 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, p= rovides > means to operate in restricted multiuser environments(HPC clusters, clo= ud and=20 > virtual environments) for groups of unprivileged users under admins con= trol [1]. > > In this circumstances CAP_SYS_PERFMON looks like smart balanced advance= ment 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 existi= ng users > and use cases. I'm not 100% opposed to CAP_SYS_PERFMON. I am 100% opposed to new capabil= ities that have a single use. Surely there are other CAP_SYS_ADMIN users that [= cs]ould be converted to CAP_SYS_PERFMON as well. If there is a class of system pe= rformance privileged operations, say a dozen or so, you may have a viable argument.= > > Well, yes, it is really good that Linux nowadays provides a handful of = various > security assuring mechanisms but proper balance is what usually makes v= aluable > features happen and its users happy and moves forward.=20 > > Gratefully, > Alexey > > [1] https://www.kernel.org/doc/html/latest/admin-guide/perf-security.ht= ml