Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1208623pxx; Tue, 27 Oct 2020 10:44:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFfP1j/fnmTdfxWv6hKh+MYCyOffg6cDc+2NJj8R5HKTLjFsAj2tBN/mdYZ2ln/fNraa+c X-Received: by 2002:a17:906:138a:: with SMTP id f10mr3628063ejc.360.1603820647806; Tue, 27 Oct 2020 10:44:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603820647; cv=none; d=google.com; s=arc-20160816; b=jt7AYI2/mPcImIj9jF3dxoXuwC4Dfb3P7cih0Xy/llLUEcexadDRFSaEH4oNR8I+D7 2WCqUCyTyz9OvIeY25coAQjkYa2eCxE5xhd2/S31HN2zl496RI9D791fXlZCT3KhtJ3C FQtoXK7ub9QLLFED67gG6D3jZK55nbzxwjDfgJOMlw3+eJ4CDQWLNn4g7aCNBM1yy4j8 VZzstLC4CfNxIUIWnGjLNzQen6ZUOSkxXq27uNu22bOKEh9eUs3HlbVlFwzO0nhcGpGG n85edBniLsQAYHzon7AlUHHVWN//9ssUV7zXe8nD/lNLE0qmKEa6/ErM1Fx224NUZIuF IyQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=Jye+0pQzhu/6eNfK7KdcGftvie8UVb0xwxj7gElagic=; b=vnIIX5/RxJRG3mZ80SzMrQ9yq4H9oPTpOG6LxKN+iHirB1ejHVOwMrAVZ+j8t4AHVv xPtivcHf/PrOE6C8qTeeFSoAsmJPM5zI3wDG5U7xs1vV/CAokMYizn45+2c4JkwOleEP VvLxAJOC99otKTqy1j9wBWqsSFu+zf1iR3YX5bgAv/bh9dF7qsdBWHmIgtqGIlXwdwtl 4vzb7uYeDRHXWzfBNxYtneHngCvP9wPj4ktNEuJmKls0VjsHBiiwo0KkNxayTylTvD6I cD+ghSCMFiTJOHfZ1/4qgv/mJy3eQuoMJfZJVAn9bv2afQFkGw3Q3yPnscSbxdEqimE2 9XrQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id lz5si1491318ejb.467.2020.10.27.10.43.45; Tue, 27 Oct 2020 10:44:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1816950AbgJ0RKq (ORCPT + 99 others); Tue, 27 Oct 2020 13:10:46 -0400 Received: from mga11.intel.com ([192.55.52.93]:57654 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1816920AbgJ0RKc (ORCPT ); Tue, 27 Oct 2020 13:10:32 -0400 IronPort-SDR: TVc4yl5lY2D4BR4vZfkM9wZjOofIU9WDvFC+ZzHXlc/2CjSThfv32hW5okeT3Bw3d6NX9xzxXW 4F9ZCt1P1csw== X-IronPort-AV: E=McAfee;i="6000,8403,9787"; a="164624505" X-IronPort-AV: E=Sophos;i="5.77,424,1596524400"; d="scan'208";a="164624505" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2020 10:10:30 -0700 IronPort-SDR: LKjGwKt+44iy+RU2amux+SXOprNH2dEvuFuxb8NqM6t2cDRU+rnT28BO0ufX3ySMCk8Jvwal8H TQfnVSS5Gyxg== X-IronPort-AV: E=Sophos;i="5.77,424,1596524400"; d="scan'208";a="535877644" Received: from abudanko-mobl.ccr.corp.intel.com (HELO [10.249.227.94]) ([10.249.227.94]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2020 10:10:26 -0700 Subject: Re: [PATCH v2] perf_event_open.2: update the man page with CAP_PERFMON related information To: "Michael Kerrisk (man-pages)" Cc: Arnaldo Carvalho de Melo , Jiri Olsa , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-man , "linux-security-module@vger.kernel.org" , linux-kernel References: <33c10554-c0ee-9e46-2946-67a9deac6752@linux.intel.com> <190971ba-31f1-ca41-60a9-38989fe82a64@gmail.com> From: Alexey Budankov Organization: Intel Corp. Message-ID: Date: Tue, 27 Oct 2020 20:10:24 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <190971ba-31f1-ca41-60a9-38989fe82a64@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27.10.2020 19:57, Michael Kerrisk (man-pages) wrote: > Hello Alexey, > > On 10/27/20 5:48 PM, Alexey Budankov wrote: >> >> Extend perf_event_open 2 man page with the information about >> CAP_PERFMON capability designed to secure performance monitoring >> and observability operation in a system according to the principle >> of least privilege [1] (POSIX IEEE 1003.1e, 2.2.2.39). >> >> [1] https://sites.google.com/site/fullycapable/, posix_1003.1e-990310.pdf >> >> Signed-off-by: Alexey Budankov > > Thanks for this. I've applied. I have a few questions/comments below. > >> --- >> man2/perf_event_open.2 | 32 ++++++++++++++++++++++++++++++-- >> 1 file changed, 30 insertions(+), 2 deletions(-) >> >> diff --git a/man2/perf_event_open.2 b/man2/perf_event_open.2 >> index 4827a359d..9810bc554 100644 >> --- a/man2/perf_event_open.2 >> +++ b/man2/perf_event_open.2 >> @@ -97,6 +97,8 @@ when running on the specified CPU. >> .BR "pid == \-1" " and " "cpu >= 0" >> This measures all processes/threads on the specified CPU. >> This requires >> +.B CAP_PERFMON >> +(since Linux 5.8) or >> .B CAP_SYS_ADMIN >> capability or a >> .I /proc/sys/kernel/perf_event_paranoid >> @@ -108,9 +110,11 @@ This setting is invalid and will return an error. >> When >> .I pid >> is greater than zero, permission to perform this system call >> -is governed by a ptrace access mode >> +is governed by >> +.B CAP_PERFMON >> +(since Linux 5.9) and a ptrace access mode > > I want to check: did you really mean 5.9 here? (Everywhere else, > 5.8 is mentioned, but perhaps this change came in the next kernel > version.) Yes, it is not a typo. This thing was merged into v5.9. Thanks, Alexei > >> .B PTRACE_MODE_READ_REALCREDS >> -check; see >> +check on older Linux versions; see >> .BR ptrace (2). >> .PP >> The >> @@ -2925,6 +2929,8 @@ to hold the result. >> This allows attaching a Berkeley Packet Filter (BPF) >> program to an existing kprobe tracepoint event. >> You need >> +.B CAP_PERFMON >> +(since Linux 5.8) or >> .B CAP_SYS_ADMIN >> privileges to use this ioctl. >> .IP >> @@ -2967,6 +2973,8 @@ have multiple events attached to a tracepoint. >> Querying this value on one tracepoint event returns the id >> of all BPF programs in all events attached to the tracepoint. >> You need >> +.B CAP_PERFMON >> +(since Linux 5.8) or >> .B CAP_SYS_ADMIN >> privileges to use this ioctl. >> .IP >> @@ -3175,6 +3183,8 @@ it was expecting. >> .TP >> .B EACCES >> Returned when the requested event requires >> +.B CAP_PERFMON >> +(since Linux 5.8) or >> .B CAP_SYS_ADMIN >> permissions (or a more permissive perf_event paranoid setting). >> Some common cases where an unprivileged process >> @@ -3296,6 +3306,8 @@ setting is specified. >> It can also happen, as with >> .BR EACCES , >> when the requested event requires >> +.B CAP_PERFMON >> +(since Linux 5.8) or >> .B CAP_SYS_ADMIN >> permissions (or a more permissive perf_event paranoid setting). >> This includes setting a breakpoint on a kernel address, >> @@ -3326,6 +3338,22 @@ The official way of knowing if >> support is enabled is checking >> for the existence of the file >> .IR /proc/sys/kernel/perf_event_paranoid . >> +.PP >> +.B CAP_PERFMON >> +capability (since Linux 5.8) provides secure approach to >> +performance monitoring and observability operations in a system >> +according to the principal of least privilege (POSIX IEEE 1003.1e). >> +Accessing system performance monitoring and observability operations >> +using >> +.B CAP_PERFMON >> +rather than the much more powerful >> +.B CAP_SYS_ADMIN >> +excludes chances to misuse credentials and makes operations more secure. >> +.B CAP_SYS_ADMIN >> +usage for secure system performance monitoring and observability >> +is discouraged with respect to >> +.B CAP_PERFMON >> +capability. > > Thank you for adding the above piece. That point of course > really needs to be emphasized! > > Thanks, > > Michael > >