All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
	Pavel Emelyanov <xemul@parallels.com>,
	Andrey Vagin <avagin@openvz.org>,
	KOSAKI Motohiro <kosaki.motohiro@gmail.com>,
	Ingo Molnar <mingo@elte.hu>, "H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Glauber Costa <glommer@parallels.com>,
	Andi Kleen <andi@firstfloor.org>, Tejun Heo <tj@kernel.org>,
	Matt Helsley <matthltc@us.ibm.com>,
	Pekka Enberg <penberg@kernel.org>,
	Eric Dumazet <eric.dumazet@gmail.com>,
	Vasiliy Kulikov <segoon@openwall.com>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	Valdis.Kletnieks@vt.edu, Michal Marek <mmarek@suse.cz>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: + syscalls-x86-add-__nr_kcmp-syscall-v8.patch added to -mm tree
Date: Wed, 15 Feb 2012 19:43:36 +0100	[thread overview]
Message-ID: <20120215184336.GA24182@redhat.com> (raw)
In-Reply-To: <20120215175319.GG4533@moon>

On 02/15, Cyrill Gorcunov wrote:
>
> On Wed, Feb 15, 2012 at 05:22:22PM +0100, Oleg Nesterov wrote:
> >
> > > So I don't understand how it's different from what
> > > is provided in this patch. What I'm missing?
> >
> > environ_read() does
> >
> > 	mm = mm_access(task);
> > 	if (mm)
> > 		do_something(mm);
> >
> > even if it races with, say, execve(setuid_app) we can't read the
> > new ->mm.
>
> Wait, I'm confused
>
> 	process 1 (reader)	process 2 ("task" itself)
> 	mm = mm_access(task);
> 				task changes own credentials
> 				so reader can't access on next
> 				read if it would try, but since
> 				access already granted... it
> 				continues do_something(mm)
> 	if (mm)
> 		do_something(mm);
>
> So in the patch I tried the same, once access is granted it
> belongs to a caller.

See the "execve(setuid_app)", this is what I meant. Even if we
race with execve() and the task raises its privileges we can't
read the new ->mm, we will read the old mm for which we have
(had) the rights to access.

> > while your code (very roughly) does something like
> >
> > 	mm = mm_access(task);
> > 	if (mm)
> > 		do_something(task->mm);
> >
> > while it is quite possible that mm != task->mm.
>
> Oleg, could you please explain me where it happens
> that task->mm (I've got access to) will be changed
> to some new -mm while I'm inspecting it.

Cough... this is question I am trying to ask ;)

Let me try again. To simplify, lets discuss the KCMP_VM case
only.

I do not really understand why do we need ptrace_may_access().
I do not see any security problems with kcmp_ptr(task->mm), but
I am not expert.

However, you added this check so I assume you have some reason.
But this can race with execve(setuid_app) and KCMP_VM can play
with task->mm after this task raises its caps. If this is fine,
then why do we need ptrace_may_access?

OK, please ignore. I sent the initial email just becase KCMP_FILE
is buggy.

> > > +       for (i = 0; i < KCMP_TYPES; i++)
> > > +               cookies[i][1] |= (~(~0UL >>  1) | 1);
> >
> > I am puzzled, help ;) this is equal to
> >
> > 		cookies[i][1] |= -LONG_MAX;
> > or
> > 		cookies[i][1] |= (LONG_MIN | 1);
> >
> > for what? why do we want to set these 2 bits (MSB and LSB) ?
>
> Letme quote hpa@ here :)
>
>  | This code is wrong.  You will have a zero cookie, legitimately, once in
>  | 2^32 or 2^64 attempts, depending on the bitness.
>  |
>  | The other thing is that for the multiplicative cookie you should OR in
>  | the value (~(~0UL >> 1) | 1) in order to make sure that the value is (a)
>  | large and (b) odd.

OK, thanks.

Oleg.


  reply	other threads:[~2012-02-15 18:51 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-15 14:36 + syscalls-x86-add-__nr_kcmp-syscall-v8.patch added to -mm tree Oleg Nesterov
2012-02-15 15:10 ` Cyrill Gorcunov
2012-02-15 15:38   ` Oleg Nesterov
2012-02-15 16:13     ` Cyrill Gorcunov
2012-02-15 16:22       ` Oleg Nesterov
2012-02-15 17:53         ` Cyrill Gorcunov
2012-02-15 18:43           ` Oleg Nesterov [this message]
2012-02-15 19:56             ` Cyrill Gorcunov
2012-02-15 19:57               ` Vasiliy Kulikov
2012-02-15 20:05                 ` Cyrill Gorcunov
2012-02-15 20:25                   ` Cyrill Gorcunov
2012-02-15 21:09                     ` Cyrill Gorcunov
2012-02-15 21:58                       ` Cyrill Gorcunov
2012-02-16 14:49                         ` Oleg Nesterov
2012-02-16 15:13                           ` Cyrill Gorcunov
2012-02-16 16:49                             ` Cyrill Gorcunov
2012-02-16 17:40                               ` Oleg Nesterov
2012-02-16 17:58                                 ` Cyrill Gorcunov
2012-02-16 19:03                                   ` Oleg Nesterov
2012-02-16 19:20                                     ` H. Peter Anvin
2012-02-16 19:29                                     ` Cyrill Gorcunov
2012-02-16 19:52                                       ` Andrew Morton
2012-02-16 20:01                                         ` Cyrill Gorcunov
2012-02-16 18:21                               ` Vasiliy Kulikov
2012-02-16 18:34                                 ` Cyrill Gorcunov
2012-02-16 18:33                                   ` Vasiliy Kulikov
2012-02-16 18:49                                 ` Oleg Nesterov
2012-02-15 18:32   ` Cyrill Gorcunov
2012-02-15 19:06     ` Oleg Nesterov
2012-02-15 19:18       ` Cyrill Gorcunov
2012-02-15 16:06 ` Oleg Nesterov
2012-02-15 16:27   ` Cyrill Gorcunov
2012-04-09 22:10     ` Andrew Morton
2012-04-09 22:24       ` Cyrill Gorcunov
2012-04-09 23:22         ` H. Peter Anvin
2012-04-10 22:37           ` Cyrill Gorcunov
2012-04-10 22:39             ` H. Peter Anvin
2012-04-10 22:48               ` Cyrill Gorcunov
2012-04-10 23:08             ` Oleg Nesterov
2012-04-10 23:32               ` H. Peter Anvin
2012-04-10 23:42                 ` Oleg Nesterov
2012-04-11  6:39                   ` Cyrill Gorcunov
2012-04-11 18:31                     ` Oleg Nesterov
2012-04-11  0:02           ` Valdis.Kletnieks
2012-04-10  3:25       ` Eric W. Biederman
2012-04-10 22:54         ` Cyrill Gorcunov
2012-04-10 23:58       ` Valdis.Kletnieks
2012-04-11  0:06         ` H. Peter Anvin
  -- strict thread matches above, loose matches on Subject: below --
2012-02-14 23:15 akpm

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=20120215184336.GA24182@redhat.com \
    --to=oleg@redhat.com \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=avagin@openvz.org \
    --cc=ebiederm@xmission.com \
    --cc=eric.dumazet@gmail.com \
    --cc=fweisbec@gmail.com \
    --cc=glommer@parallels.com \
    --cc=gorcunov@openvz.org \
    --cc=hpa@zytor.com \
    --cc=kosaki.motohiro@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthltc@us.ibm.com \
    --cc=mingo@elte.hu \
    --cc=mmarek@suse.cz \
    --cc=penberg@kernel.org \
    --cc=segoon@openwall.com \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    --cc=xemul@parallels.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.