linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: John Stultz <john.stultz@linaro.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Arjan van de Ven <arjan@linux.intel.com>,
	lkml <linux-kernel@vger.kernel.org>,
	Oren Laadan <orenl@cellrox.com>,
	Ruchi Kandoi <kandoiruchi@google.com>,
	Rom Lemarchand <romlem@android.com>,
	Android Kernel Team <kernel-team@android.com>,
	Todd Kjos <tkjos@google.com>, Colin Cross <ccross@android.com>,
	Nick Kralevich <nnk@google.com>,
	Dmitry Shmidt <dimitrysh@google.com>,
	Elliott Hughes <enh@google.com>
Subject: Re: [PATCH 2/2] proc: Add /proc/<pid>/timerslack_ns interface
Date: Wed, 13 Jul 2016 20:39:45 -0700	[thread overview]
Message-ID: <CAGXu5jJwAVdKBKUgWgGvwoHn8p7bNWMVK8+BNqmaE+Q7TrT1rA@mail.gmail.com> (raw)
In-Reply-To: <CALAqxLUsJ8Aph76mJ9xZWry56xvL8wKy+HVbgh=NQ-fimFUtJg@mail.gmail.com>

On Wed, Jul 13, 2016 at 4:47 PM, John Stultz <john.stultz@linaro.org> wrote:
> On Tue, Feb 16, 2016 at 5:06 PM, John Stultz <john.stultz@linaro.org> wrote:
>> This patch provides a proc/PID/timerslack_ns interface which
>> exposes a task's timerslack value in nanoseconds and allows it
>> to be changed.
>>
>> This allows power/performance management software to set timer
>> slack for other threads according to its policy for the thread
>> (such as when the thread is designated foreground vs. background
>> activity)
>>
>> If the value written is non-zero, slack is set to that value.
>> Otherwise sets it to the default for the thread.
>>
>> This interface checks that the calling task has permissions to
>> to use PTRACE_MODE_ATTACH_FSCREDS on the target task, so that we
>> can ensure arbitrary apps do not change the timer slack for other
>> apps.
>
> Sigh.
>
> So I wanted to pull this thread up again, because when I originally
> proposed upstreaming the PR_SET_TIMERSLACK_PID feature from the AOSP
> common.git tree, the first objection from Arjan was that it only
> required CAP_SYS_NICE:
>    http://lkml.iu.edu/hypermail/linux/kernel/1506.3/01491.html
>
> And reasonably, setting timerslack to very large values does have the
> potential to effect applications much further then what a task could
> do previously with CAP_SYS_NICE.
>
> CAP_SYS_PTRACE was suggested instead, as that allows applications to
> manipulate other tasks more drastically.
>
> (At the time, I checked with some of the Android developers, and got
> no objection to changing to use this capability.)
>
> However, after submitting the changes to Android required to support
> the upstreamed /proc/<tid>/timerslack_ns interface, I've gotten some
> objections with adding CAP_SYS_PTRACE to the system_server, as this
> would allow the system_server to be able to inspect and modify memory
> on any task in the system. This gives the system_server privileged to
> effect applications much further then what it could do previously.
>
> So I worry I'm a bit stuck here. For general systems, CAP_SYS_NICE is
> too low a level of privilege  to set a tasks timerslack, but
> apparently CAP_SYS_PTRACE is too high a privilege for Android's
> system_server to require just to set a tasks timerslack value.
>
> So I wanted to ask again if we might consider backing this down to
> CAP_SYS_NICE, or if we can instead introduce a new CAP_SYS_TIMERSLACK
> or something to provide the needed in-between capability level.

Adding new capabilities appears to not really be viable (lots of
threads about this...)

I think the original CAP_SYS_NICE should be fine. A malicious
CAP_SYS_NICE process can do plenty of insane things, I don't feel like
the timer slack adds to any realistic risks.

-Kees

-- 
Kees Cook
Chrome OS & Brillo Security

  reply	other threads:[~2016-07-14  3:39 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-17  1:06 [PATCH 0/2] Extend timer_slack_ns to u64 on 32bit systems & add /proc/<pid>/timerslack_ns John Stultz
2016-02-17  1:06 ` [PATCH 1/2] timer: Convert timer_slack_ns from unsigned long to u64 John Stultz
2016-02-17  1:06 ` [PATCH 2/2] proc: Add /proc/<pid>/timerslack_ns interface John Stultz
2016-02-17 19:35   ` Andrew Morton
2016-02-17 20:09     ` Kees Cook
2016-02-17 20:18       ` Andrew Morton
2016-02-17 20:51         ` John Stultz
2016-02-17 21:07           ` Andrew Morton
2016-02-17 22:29         ` John Stultz
2016-02-17 22:45           ` Kees Cook
2016-02-17 22:51             ` John Stultz
2016-02-17 22:53           ` Andrew Morton
2016-02-17 20:49     ` John Stultz
2016-02-18  5:59   ` [PATCH] proc: /proc/<pid>/timerslack_ns permissions fixes John Stultz
2016-02-18 17:52     ` Kees Cook
2016-07-13 23:47   ` [PATCH 2/2] proc: Add /proc/<pid>/timerslack_ns interface John Stultz
2016-07-14  3:39     ` Kees Cook [this message]
2016-07-14  5:29       ` Arjan van de Ven
2016-07-14 12:48       ` Serge E. Hallyn
2016-07-14 13:42         ` Arjan van de Ven
2016-07-14 16:01           ` John Stultz
2016-07-14 16:09         ` John Stultz
2016-07-14 17:45           ` Kees Cook
2016-07-14 17:48             ` Arjan van de Ven
2016-07-14 17:49             ` Serge E. Hallyn
2016-07-14 17:56               ` Kees Cook
2016-07-14 20:21                 ` Serge E. Hallyn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGXu5jJwAVdKBKUgWgGvwoHn8p7bNWMVK8+BNqmaE+Q7TrT1rA@mail.gmail.com \
    --to=keescook@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=arjan@linux.intel.com \
    --cc=ccross@android.com \
    --cc=dimitrysh@google.com \
    --cc=enh@google.com \
    --cc=john.stultz@linaro.org \
    --cc=kandoiruchi@google.com \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nnk@google.com \
    --cc=orenl@cellrox.com \
    --cc=romlem@android.com \
    --cc=tglx@linutronix.de \
    --cc=tkjos@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).