Score:0

how to set capabilities (setcap) on perf

jp flag

So I asked the same question on Unix and Linux Stack Exchange, but I haven't received any answers. I'd like to use the perf utility. I was following instructions to set up a privileged group of users who are permitted to execute performance monitoring and observability without limits (as instructed here: https://www.kernel.org/doc/html/latest/admin-guide/perf-security.html). I added the group and limited access to users not in the group. I started having problems when assigning capabilities to the perf tool:

setcap cap_sys_admin,cap_sys_ptrace,cap_syslog=ep perf

I'd like to use the perf utility. I was following instructions to set up a privileged group of users who are permitted to execute performance monitoring and observability without limits (as instructed here: https://www.kernel.org/doc/html/latest/admin-guide/perf-security.html). I added the group and limited access to users not in the group. I started having problems when assigning capabilities to the perf tool:

setcap cap_sys_admin,cap_sys_ptrace,cap_syslog=ep perf

I get an invalid arguments error saying

fatal error: Invalid argument
usage: setcap [-q] [-v] [-n <rootid>] (-r|-|<caps>) <filename> [ ... (-r|-|<capsN>) <filenameN> ]

Note <filename> must be a regular (non-symlink) file.

But running stats perf gives me this

  File: ./perf
  Size: 1622        Blocks: 8          IO Block: 4096   regular file
Device: 10307h/66311d   Inode: 35260925    Links: 1
Access: (0750/-rwxr-x---)  Uid: (    0/    root)   Gid: ( 1001/perf_users)
Access: 2021-12-03 13:08:48.923220351 +0100
Modify: 2021-11-05 17:02:56.000000000 +0100
Change: 2021-12-03 12:31:49.451991980 +0100
 Birth: -

which says the file is a regular file. What could be the problem? How can I set the capabilities for the Perf tool?

hr flag
Are you running the setcap command from the perf command's containing directory (/usr/bin or /bin)?
levente.nas avatar
jp flag
Yes, I'm running the setcap command from /usr/bin.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.