[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171003145308.aro4mtwg4z4nuzw5@hirez.programming.kicks-ass.net>
Date: Tue, 3 Oct 2017 16:53:08 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Ingo Molnar <mingo@...hat.com>, linux-kernel@...r.kernel.org,
acme@...hat.com, kirill.shutemov@...ux.intel.com,
Borislav Petkov <bp@...en8.de>, rric@...nel.org
Subject: Re: [RFC PATCH 15/17] perf: Allow controlled non-root access to
detached events
On Tue, Sep 05, 2017 at 04:30:24PM +0300, Alexander Shishkin wrote:
> @@ -5587,7 +5587,13 @@ static int perf_open(struct inode *inode, struct file *file)
> if (!atomic_long_inc_not_zero(&event->refcount))
> return -ENOENT;
>
> - ret = simple_open(inode, file);
> + /* event's user is stable while we're holding the reference */
> + if (event->rb->mmap_user != current_user() &&
> + !capable(CAP_SYS_ADMIN))
> + ret = -EACCES;
> +
> + if (!ret)
> + ret = simple_open(inode, file);
> if (ret)
> put_event(event);
>
> @@ -11530,6 +11537,18 @@ static int perf_instance_unlink(const char *name)
> if (!event)
> return -EINVAL;
>
> + if (!atomic_long_inc_not_zero(&event->refcount))
> + return 0;
> +
> + /* event's user is stable while we're holding the reference */
> + if (event->rb->mmap_user != current_user() &&
> + !capable(CAP_SYS_ADMIN))
> + ret = -EACCES;
> + put_event(event);
> +
> + if (ret)
> + return ret;
> +
> if (!(event->attach_state & PERF_ATTACH_CONTEXT))
> return -EBUSY;
>
Why aren't we using regular file permissions for this?
Powered by blists - more mailing lists