lkml.org 
[lkml]   [2017]   [Oct]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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?

\
 
 \ /
  Last update: 2017-10-03 16:54    [W:0.130 / U:0.216 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site