Re: [PATCH 1/8] perf: Allow to block process in syscall tracepoints

From: Peter Zijlstra
Date: Thu Dec 06 2018 - 03:17:20 EST


On Wed, Dec 05, 2018 at 05:05:02PM +0100, Jiri Olsa wrote:
> @@ -10461,6 +10484,19 @@ SYSCALL_DEFINE5(perf_event_open,
> return -EINVAL;
> }
>
> + if (attr.block) {
> + /*
> + * Allow only syscall tracepoints, check for syscall class
> + * is made in the tracepoint event_init callback.
> + */
> + if (attr.type != PERF_TYPE_TRACEPOINT)
> + return -EINVAL;
> +
> + /* Allow to block only if we attach to a process. */
> + if (pid == -1)
> + return -EINVAL;
> + }
> +
> /* Only privileged users can get physical addresses */
> if ((attr.sample_type & PERF_SAMPLE_PHYS_ADDR) &&
> perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN))

That's fairly horrible and will, when copied, lead to a giant mess.

Please see the whole exclusion patch set here:

https://lkml.kernel.org/r/1543230756-15319-1-git-send-email-andrew.murray@xxxxxxx

PERF_PMU_CAP_BLOCK sounds like something you'd want here.