From: Andrew Morton <akpm@linux-foundation.org>
To: John Stultz <john.stultz@linaro.org>
Cc: 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>,
Kees Cook <keescook@chromium.org>,
Android Kernel Team <kernel-team@android.com>
Subject: Re: [PATCH 2/2] proc: Add /proc/<pid>/timerslack_ns interface
Date: Wed, 17 Feb 2016 11:35:47 -0800 [thread overview]
Message-ID: <20160217113547.6487174b9c6d365927095080@linux-foundation.org> (raw)
In-Reply-To: <1455671191-32105-3-git-send-email-john.stultz@linaro.org>
On Tue, 16 Feb 2016 17:06:31 -0800 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.
hm. What the heck is PTRACE_MODE_ATTACH_FSCREDS and why was it chosen?
The procfs file's permissions are 0644, yes? So a process's
timer_slack is world-readable? hm.
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -2257,6 +2257,74 @@ static const struct file_operations proc_timers_operations = {
> .release = seq_release_private,
> };
>
> +static ssize_t timerslack_ns_write(struct file *file, const char __user *buf,
> + size_t count, loff_t *offset)
> +{
> + struct inode *inode = file_inode(file);
> + struct task_struct *p;
> + char buffer[PROC_NUMBUF];
> + u64 slack_ns;
> + int err;
> +
> + memset(buffer, 0, sizeof(buffer));
> + if (count > sizeof(buffer) - 1)
> + count = sizeof(buffer) - 1;
> +
> + if (copy_from_user(buffer, buf, count))
> + return -EFAULT;
> +
> + err = kstrtoull(strstrip(buffer), 10, &slack_ns);
> + if (err < 0)
> + return err;
Use kstrtoull_from_user()?
> + p = get_proc_task(inode);
> + if (!p)
> + return -ESRCH;
> +
> + if (ptrace_may_access(p, PTRACE_MODE_ATTACH_FSCREDS)) {
> + if (slack_ns == 0)
> + p->timer_slack_ns = p->default_timer_slack_ns;
> + else
> + p->timer_slack_ns = slack_ns;
> + } else
> + count = -EINVAL;
> +
> + put_task_struct(p);
> +
> + return count;
> +}
> +
next prev parent reply other threads:[~2016-02-17 19:35 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 [this message]
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
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=20160217113547.6487174b9c6d365927095080@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=arjan@linux.intel.com \
--cc=john.stultz@linaro.org \
--cc=kandoiruchi@google.com \
--cc=keescook@chromium.org \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=orenl@cellrox.com \
--cc=romlem@android.com \
--cc=tglx@linutronix.de \
/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).