Skip to content

Commit d0d3e21

Browse files
Thomas RichterAlexander Gordeev
authored andcommitted
s390/cpum_cf: open access to hwctr device for CAP_PERFMON privileged process
The device /dev/hwctr was introduced to access complete CPU Measurement facility counter sets via an ioctl system call. The access the to device is limited to privileged processes running as root or superuser. The capability CAP_SYS_ADMIN is required. The device permissions are read/write for the device owner root. There is no need for this restriction. Make the device access permission read/write for all and reduce the capabilities to CAP_PERFMON. Any user space program with the CAP_PERFMON capability assigned to it can now read and display the CPU Measurement facility counter sets. For more details on perf tool usage and security, see linux documentation in Documentation/admin-guide/perf-security.rst. Signed-off-by: Thomas Richter <tmricht@linux.ibm.com> Acked-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
1 parent 11458e2 commit d0d3e21

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

arch/s390/kernel/perf_cpum_cf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ static int cfset_release(struct inode *inode, struct file *file)
12131213

12141214
static int cfset_open(struct inode *inode, struct file *file)
12151215
{
1216-
if (!capable(CAP_SYS_ADMIN))
1216+
if (!perfmon_capable())
12171217
return -EPERM;
12181218
mutex_lock(&cfset_ctrset_mutex);
12191219
if (atomic_inc_return(&cfset_opencnt) == 1)
@@ -1502,6 +1502,7 @@ static struct miscdevice cfset_dev = {
15021502
.name = S390_HWCTR_DEVICE,
15031503
.minor = MISC_DYNAMIC_MINOR,
15041504
.fops = &cfset_fops,
1505+
.mode = 0666,
15051506
};
15061507

15071508
/* Hotplug add of a CPU. Scan through all active processes and add

0 commit comments

Comments
 (0)