Skip to contentSkip to conversation

perf_event_open.2: update the man page with CAP_PERFMON related information

PATCH In review Alexey Budankov 2 participants 4 messages Oct 27, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 perf_event_open.2: update the man page with CAP_PERFMON related information

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

---
 man2/perf_event_open.2 | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)
man2/perf_event_open.2 +30 -2
index 4827a359d..9810bc554 100644
@@ -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
 .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.
 .SH BUGS
 The
 .B F_SETOWN_EX
Signature · 1 line
2.24.1
#1 lore raw

Hello Alexey,

Quoted 9 lines · Alexey Budankov

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

Thanks for this. I've applied. I have a few questions/comments below.

Quoted 18 lines
---
 man2/perf_event_open.2 | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)
man2/perf_event_open.2 +2 -0
index 4827a359d..9810bc554 100644
@@ -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

man2/perf_event_open.2 This setting is invalid and will return an error. · line 115

Quoted 7 lines
man2/perf_event_open.2 +3 -1
@@ -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.)

Quoted 52 lines
man2/perf_event_open.2 +15 -1
 .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

man2/perf_event_open.2 The official way of knowing if · line 3356

Quoted 10 lines
man2/perf_event_open.2 +10 -0
+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

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#2 lore raw
Quoted 36 lines · Michael Kerrisk (man-pages)

Hello Alexey,

Quoted 9 lines · Alexey Budankov

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

Thanks for this. I've applied. I have a few questions/comments below.

Quoted 21 lines
---
 man2/perf_event_open.2 | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)
man2/perf_event_open.2 +2 -0
index 4827a359d..9810bc554 100644
@@ -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
Quoted 8 lines

man2/perf_event_open.2 This setting is invalid and will return an error. · line 115

Quoted 4 lines
man2/perf_event_open.2 +3 -1
-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

Quoted 72 lines
Quoted 53 lines
man2/perf_event_open.2 +15 -1
 .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

man2/perf_event_open.2 The official way of knowing if · line 3356

Quoted 10 lines
man2/perf_event_open.2 +10 -0
+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

#3 lore raw
Quoted 48 lines · Alexey Budankov
Quoted 36 lines · Michael Kerrisk (man-pages)

Hello Alexey,

Quoted 9 lines · Alexey Budankov

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

Thanks for this. I've applied. I have a few questions/comments below.

Quoted 21 lines
---
 man2/perf_event_open.2 | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)
man2/perf_event_open.2 +2 -0
index 4827a359d..9810bc554 100644
@@ -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
Quoted 8 lines

man2/perf_event_open.2 This setting is invalid and will return an error. · line 115

Quoted 4 lines
man2/perf_event_open.2 +3 -1
-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.)

Quoted 4 lines

Yes, it is not a typo. This thing was merged into v5.9.

Thanks,
Alexei

Thanks, Alexei!

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/