Re: [RFC 0/5] perf: Per PMU access controls (paranoid setting)
From: Thomas Gleixner
Date: Mon Oct 01 2018 - 12:12:12 EST
Alexey,
On Mon, 1 Oct 2018, Alexey Budankov wrote:
> > On Fri, Sep 28, 2018 at 11:22:37PM +0200, Jann Horn wrote:
> >> <blasphemy>
> >> Is that true? IIRC if you want to use the perf tools after a kernel
> >> update, you have to install a new version of perf anyway, no?
>
> There are usages in production where perf_event_open() syscall
> accompanied with read(), mmap() etc. is embedded into application
> on per-thread basis and is used for self monitoring and dynamic
> execution tuning.
>
> There are also other Perf tools around that, for example, are
> statically linked and then used as on Linux as on Android.
>
> Backward compatibility does matter in these cases.
Well, it's nothing fundamentally new, that new features require changes to
applications, libraries etc. It's nice if it can be avoided of course.
>From a design POV, Jann's idea to have a per PMU special file which you
need to open for getting access is way better than the extra knobs. It
allows to use all existing security mechanisms to be used.
Peter and I discussed that and we came up with the idea that the file
descriptor is not even required, i.e. you could make it backward
compatible.
perf_event_open() knows which PMU is associated with the event the caller
tries to open. So perf_event_open() can try to access/open the special per
PMU file on behalf of the caller. That should get the same security
treatment like a regular open() from user space. If that succeeds, access
is granted.
The magic file could still be writeable for root to give general
restrictions aside of the file based ones similar to what you are
proposing.
The analysis and documentation requirements still remain of course.
Thanks,
tglx