Re: perf top -u <uid> does not seem to be working

From: Arnaldo Carvalho de Melo
Date: Wed Nov 13 2013 - 12:59:49 EST


Em Wed, Nov 13, 2013 at 12:22:49AM +0100, Ingo Molnar escreveu:
> Hm, this is unexpected I think:
>
> hubble:~> perf top --stdio -u mingo
> Error:
> You may not have permission to collect stats.
> Consider tweaking /proc/sys/kernel/perf_event_paranoid:
> -1 - Not paranoid at all
> 0 - Disallow raw tracepoint access for unpriv
> 1 - Disallow cpu events for unpriv
> 2 - Disallow kernel profiling for unpriv
>
> hubble:~> cat /proc/sys/kernel/perf_event_paranoid
> -1
>
> (perf is the latest version from tip:perf/core)

https://lkml.org/lkml/2012/1/26/142

Fell thru the cracks, summary:

> > > +++ b/kernel/events/core.c
> > > @@ -2636,7 +2636,8 @@ find_lively_task_by_vpid(pid_t vpid)
> > > /* Reuse ptrace permission checks for now. */
> > > err = -EACCES;
> > > - if (!ptrace_may_access(task, PTRACE_MODE_READ))
> > > + if (perf_paranoid_tracepoint_raw() &&
> > > + !ptrace_may_access(task, PTRACE_MODE_READ))
> > > goto errout;
> > > return task;

> > > ptrace_may_access(task, PTRACE_MODE_READ) fails for some tasks
> > > owned by the user because, IIRC, in __ptrace_may_access:

> > Which tasks are these, are they privileged in any sense?

> IIRC one of them was a child of sshd, that runs as root and then changes
> the child ownership to the user logging in.

- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/