Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Tue, 27 Nov 2018 09:55:35 +0300
From: Alexey Budankov <alexey.budankov@...ux.intel.com>
To: Jonathan Corbet <corbet@....net>
Cc: Thomas Gleixner <tglx@...utronix.de>, Kees Cook <keescook@...omium.org>,
 Jann Horn <jannh@...gle.com>, Ingo Molnar <mingo@...hat.com>,
 Peter Zijlstra <peterz@...radead.org>,
 Arnaldo Carvalho de Melo <acme@...nel.org>, Andi Kleen <ak@...ux.intel.com>,
 Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
 Jiri Olsa <jolsa@...hat.com>, Namhyung Kim <namhyung@...nel.org>,
 Mark Rutland <mark.rutland@....com>, Tvrtko Ursulin <tursulin@...ulin.net>,
 linux-kernel <linux-kernel@...r.kernel.org>,
 "kernel-hardening@...ts.openwall.com" <kernel-hardening@...ts.openwall.com>,
 "linux-doc@...r.kernel.org" <linux-doc@...r.kernel.org>
Subject: Re: [PATCH v2 1/2] Documentation/admin-guide: introduce
 perf-security.rst file

On 26.11.2018 23:28, Jonathan Corbet wrote:
> On Mon, 26 Nov 2018 11:57:21 +0300
> Alexey Budankov <alexey.budankov@...ux.intel.com> wrote:
> 
>>>> +For the purpose of performing security checks Linux implementation splits
>>>> +processes into two categories [6]_ : a) privileged processes (whose effective
>>>> +user ID is 0, referred to as superuser or root), and b) unprivileged processes
>>>> +(whose effective UID is nonzero).  
>>>
>>> Is that really what's going on here?  If I understand things correctly,
>>> it's looking for CAP_SYS_PTRACE rather than a specific UID; am I missing
>>> something here?  
>>
>> You are right regarding CAP_SYS_PTRACE but this capability is not the only 
>> one which is used by perf_events for security checks, so the capabilities 
>> clarification is kept aside of these patches, because patches initial intention 
>> is to clarify security specifics of sysctl_perf_even_paranoid settings.
>>
>> I agree that the document can be extended with details clarifying capabilities 
>> used by perf_events for security checks.
> 
> I don't really like the idea of adding a document that we know doesn't
> really describe how the security decision is made.  Even a one-line
> parenthetical saying that things are more complicated and giving a pointer
> to a place to look for details would help, IMO.

Well, makes sense. It is possible to have something similar to this:

...

For the purpose of performing security checks the Linux implementation splits
processes into two categories [6]_ : a) privileged processes (whose effective
user ID is 0, referred to as superuser or root), and b) unprivileged processes
(whose effective UID is nonzero).

Privileged processes bypass all kernel security permission checks so perf_events
performance monitoring is fully available to privileged processes without
access, scope and resource restrictions.

Unprivileged processes are subject to full security permission check based on 
the process's credentials [5]_ (usually: effective UID, effective GID, and 
supplementary group list).

Linux divides the privileges traditionally associated with superuser into
distinct units, known as capabilities [6]_, which can be independently enabled
and disabled on per-thread basis for processes and files of unprivileged users.

Unprivileged processes with enabled CAP_SYS_ADMIN capability are treated as 
privileged processes with respect to perf_events performance monitoring and
bypass *scope* permissions checks in the kernel.

Unprivileged processes using perf_events system call API is also subject for
PTRACE_MODE_READ_REALCREDS ptrace access mode check [7]_ , whose outcome determines
whether monitoring is permitted. So unprivileged process provided with
CAP_SYS_PTRACE capability are effectively permitted to pass the check.

Other capabilities being granted to unprivileged processes can effectively
enable capturing of additional data required for later performance analysis of
monitored processes or system. For example CAP_SYSLOG capability permits
reading kernel space memory addresses from /proc/kallsyms file.

...

Thanks,
Alexey

> 
> Either way, I can merge this, but I'd like to have an ack from the perf
> folks first.
> 
> Thanks,
> 
> jon
> 

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.