OSDN Git Service

powerpc/perf: Add privileged access check for thread_imc
authorMadhavan Srinivasan <maddy@linux.vnet.ibm.com>
Tue, 16 Apr 2019 09:48:29 +0000 (15:18 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 2 May 2019 16:54:59 +0000 (02:54 +1000)
Add code to restrict user access to thread_imc pmu since
some event report privilege level information.

Fixes: f74c89bd80fb3 ("powerpc/perf: Add thread IMC PMU support")
Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
Signed-off-by: Anju T Sudhakar <anju@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/perf/imc-pmu.c

index 23092a3..975837d 100644 (file)
@@ -864,6 +864,9 @@ static int thread_imc_event_init(struct perf_event *event)
        if (event->attr.type != event->pmu->type)
                return -ENOENT;
 
+       if (!capable(CAP_SYS_ADMIN))
+               return -EACCES;
+
        /* Sampling not supported */
        if (event->hw.sample_period)
                return -EINVAL;