Lock down perf
authorDavid Howells <dhowells@redhat.com>
Mon, 18 Feb 2019 12:45:02 +0000 (12:45 +0000)
committerSalvatore Bonaccorso <carnil@debian.org>
Thu, 26 Sep 2019 12:19:06 +0000 (13:19 +0100)
Disallow the use of certain perf facilities that might allow userspace to
access kernel data.

Signed-off-by: David Howells <dhowells@redhat.com>
Gbp-Pq: Topic features/all/lockdown
Gbp-Pq: Name 0026-Lock-down-perf.patch

kernel/events/core.c

index 1a8eb4dd99be972279d1fb9eaaee1a519052b69b..f30bce79d616e5671e9df045eab4cb43219ee16a 100644 (file)
@@ -10824,6 +10824,11 @@ SYSCALL_DEFINE5(perf_event_open,
                        return -EINVAL;
        }
 
+       if ((attr.sample_type & PERF_SAMPLE_REGS_INTR) &&
+           kernel_is_locked_down("PERF_SAMPLE_REGS_INTR"))
+               /* REGS_INTR can leak data, lockdown must prevent this */
+               return -EPERM;
+
        /* Only privileged users can get physical addresses */
        if ((attr.sample_type & PERF_SAMPLE_PHYS_ADDR) &&
            perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN))