From: Vasiliy Kulikov <segoon@openwall.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Balbir Singh <bsingharora@gmail.com>,
Shailabh Nagar <nagar@us.ibm.com>,
linux-kernel@vger.kernel.org, security@kernel.org,
Eric Paris <eparis@redhat.com>, Stephen Wilson <wilsons@start.ca>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
David Rientjes <rientjes@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Balbir Singh <balbir@linux.vnet.ibm.com>,
kernel-hardening@lists.openwall.com
Subject: Re: [Security] [PATCH 2/2] taskstats: restrict access to user
Date: Mon, 19 Sep 2011 21:39:05 +0400 [thread overview]
Message-ID: <20110919173905.GA3804@albatros> (raw)
In-Reply-To: <CA+55aFxXS9z=NwoYug+qGoYufqN-6dCo4fm5ggTsoDonsMi4Dw@mail.gmail.com>
On Mon, Sep 19, 2011 at 09:40 -0700, Linus Torvalds wrote:
> diff --git a/kernel/taskstats.c b/kernel/taskstats.c
> index e19ce1454ee1..5874d4866b3c 100644
> --- a/kernel/taskstats.c
> +++ b/kernel/taskstats.c
> @@ -457,6 +457,8 @@ static int cmd_attr_register_cpumask(struct genl_info *info)
> cpumask_var_t mask;
> int rc;
>
> + if (!capable(CAP_SYS_ADMIN))
> + return -EPERM;
Shouldn't it simply protect taskstats_user_cmd()? You may still poll
the counters with TASKSTATS_CMD_ATTR_PID/TASKSTATS_CMD_ATTR_TGID.
Or ptrace_may_access() in taskstats_user_cmd().
> if (!alloc_cpumask_var(&mask, GFP_KERNEL))
> return -ENOMEM;
> rc = parse(info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK], mask);
> diff --git a/kernel/tsacct.c b/kernel/tsacct.c
> index 24dc60d9fa1f..110ca5a03bd6 100644
> --- a/kernel/tsacct.c
> +++ b/kernel/tsacct.c
> @@ -78,6 +78,7 @@ void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk)
>
> #define KB 1024
> #define MB (1024*KB)
> +#define KB_MASK (~(KB-1))
> /*
> * fill in extended accounting fields
> */
> @@ -100,9 +101,9 @@ void xacct_add_tsk(struct taskstats *stats, struct task_struct *p)
> stats->read_syscalls = p->ioac.syscr;
> stats->write_syscalls = p->ioac.syscw;
> #ifdef CONFIG_TASK_IO_ACCOUNTING
> - stats->read_bytes = p->ioac.read_bytes;
> - stats->write_bytes = p->ioac.write_bytes;
> - stats->cancelled_write_bytes = p->ioac.cancelled_write_bytes;
> + stats->read_bytes = p->ioac.read_bytes & KB_MASK;
> + stats->write_bytes = p->ioac.write_bytes & KB_MASK;
> + stats->cancelled_write_bytes = p->ioac.cancelled_write_bytes & KB_MASK;
> #else
> stats->read_bytes = 0;
> stats->write_bytes = 0;
--
Vasiliy Kulikov
http://www.openwall.com - bringing security into open computing environments
next prev parent reply other threads:[~2011-09-19 17:39 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-24 12:09 [PATCH 2/2] taskstats: restrict access to user Vasiliy Kulikov
2011-06-29 1:27 ` Balbir Singh
2011-06-29 11:42 ` Vasiliy Kulikov
2011-06-29 20:17 ` Vasiliy Kulikov
2011-07-02 7:36 ` Vasiliy Kulikov
2011-07-04 2:57 ` Balbir Singh
2011-07-04 17:45 ` Vasiliy Kulikov
2011-07-07 8:55 ` Vasiliy Kulikov
2011-07-07 11:53 ` Balbir Singh
2011-07-07 16:23 ` Vasiliy Kulikov
2011-07-09 15:36 ` Balbir Singh
2011-07-11 14:07 ` Vasiliy Kulikov
2011-06-29 20:09 ` [Security] " Linus Torvalds
2011-06-30 7:57 ` Vasiliy Kulikov
2011-06-30 10:59 ` Balbir Singh
2011-06-30 12:08 ` Vasiliy Kulikov
2011-06-30 16:40 ` Linus Torvalds
2011-07-01 3:02 ` Balbir Singh
2011-09-19 16:40 ` Linus Torvalds
2011-09-19 17:20 ` Balbir Singh
2011-09-19 17:39 ` Vasiliy Kulikov [this message]
2011-09-19 17:45 ` Linus Torvalds
2011-09-20 3:35 ` Eric W. Biederman
2011-09-20 5:47 ` Alexey Dobriyan
2011-09-19 17:47 ` Balbir Singh
2011-09-19 18:29 ` Andi Kleen
2011-09-19 18:32 ` Linus Torvalds
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=20110919173905.GA3804@albatros \
--to=segoon@openwall.com \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=bsingharora@gmail.com \
--cc=eparis@redhat.com \
--cc=kernel-hardening@lists.openwall.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nagar@us.ibm.com \
--cc=rientjes@google.com \
--cc=security@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=wilsons@start.ca \
/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).