Re: [PATCH RFC] perf_event: Add support for LSM and SELinux checks
From: Joel Fernandes
Date: Fri Oct 11 2019 - 11:47:39 EST
On Fri, Oct 11, 2019 at 09:05:43AM +0200, Peter Zijlstra wrote:
> On Thu, Oct 10, 2019 at 02:31:14PM -0400, Joel Fernandes wrote:
> > On Thu, Oct 10, 2019 at 07:09:49PM +0200, Peter Zijlstra wrote:
>
> > > Yes, I did notice, I found it weird.
> > >
> > > If you have CAP_IPC_LIMIT you should be able to bust mlock memory
> > > limits, so I don't see why we should further relate that to paranoid.
> > >
> > > The way I wrote it, we also allow to bust the limit if we have disabled
> > > all paranoid checks. Which makes some sense I suppose.
> > >
> > > The original commit is this:
> > >
> > > 459ec28ab404 ("perf_counter: Allow mmap if paranoid checks are turned off")
> >
> > I am thinking we can just a new function perf_is_paranoid() that has nothing
> > to do with the CAP_SYS_ADMIN check and doesn't have tracepoint wording:
> >
> > static inline int perf_is_paranoid(void)
> > {
> > return sysctl_perf_event_paranoid > -1;
> > }
> >
> > And then call that from the mmap() code:
> > if (locked > lock_limit && perf_is_paranoid() && !capable(CAP_IPC_LOCK)) {
> > return -EPERM;
> > }
> >
> > I don't think we need to add selinux security checks here since we are
> > already adding security checks earlier in mmap(). This will make the code and
> > its intention more clear and in line with the commit 459ec28ab404 you
> > mentioned. Thoughts?
>
> Mostly that I'm confused by the current code ;-)
>
> Like I said, CAP_IPC_LIMIT on its own should already allow busting the
> limit, I don't really see why we should make it conditional on paranoid.
>
> But if you want to preserve behaviour (arguably a sane thing for your
> patch) then yes, feel free to do as you propose.
Ok, I will do it as I proposed above and resend patch today. Thanks!
- Joel