Re: [PATCH v3 07/11] perf: Add breakpoint information to siginfo on SIGTRAP
From: Peter Zijlstra
Date: Wed Mar 24 2021 - 09:44:10 EST
On Wed, Mar 24, 2021 at 02:21:37PM +0100, Peter Zijlstra wrote:
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -5652,13 +5652,17 @@ static long _perf_ioctl(struct perf_even
> return perf_event_query_prog_array(event, (void __user *)arg);
>
> case PERF_EVENT_IOC_MODIFY_ATTRIBUTES: {
> + struct perf_event_attr __user *uattr;
> struct perf_event_attr new_attr;
> - int err = perf_copy_attr((struct perf_event_attr __user *)arg,
> - &new_attr);
> + int err;
>
> + uattr = (struct perf_event_attr __user *)arg;
> + err = perf_copy_attr(uattr, &new_attr);
> if (err)
> return err;
>
> + event->siginfo.si_perf = (unsigned long)uattr;
Oh bugger; that wants updating for all children too..
> +
> return perf_event_modify_attr(event, &new_attr);
> }
> default:
> @@ -12011,6 +12010,11 @@ SYSCALL_DEFINE5(perf_event_open,
> goto err_task;
> }
>
> + clear_siginfo(&event->siginfo);
> + event->siginfo.si_signo = SIGTRAP;
> + event->siginfo.si_code = TRAP_PERF;
> + event->siginfo.si_perf = (unsigned long)attr_uptr;
And inherit_event() / perf_event_alloc() want to copy/propagate that.
> if (is_sampling_event(event)) {
> if (event->pmu->capabilities & PERF_PMU_CAP_NO_INTERRUPT) {
> err = -EOPNOTSUPP;