All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Kees Cook <keescook@chromium.org>,
	Andrey Vagin <avagin@virtuozzo.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Pavel Emelyanov <xemul@virtuozzo.com>,
	Linux Containers <containers@lists.linux-foundation.org>
Subject: Re: [ISSUE] mm: Add a user_ns owner to mm_struct and fix ptrace_may_access
Date: Tue, 25 Oct 2016 12:02:13 +0300	[thread overview]
Message-ID: <20161025090213.GX1847@uranus.lan> (raw)
In-Reply-To: <8760oh737b.fsf@xmission.com>

On Mon, Oct 24, 2016 at 06:11:04PM -0500, Eric W. Biederman wrote:
> Kees Cook <keescook@chromium.org> writes:
> 
> > On Mon, Oct 24, 2016 at 1:29 PM, Cyrill Gorcunov <gorcunov@gmail.com> wrote:
> >> On Mon, Oct 24, 2016 at 02:01:30PM -0500, Eric W. Biederman wrote:
> >>> So I am probably going to tweak the !mm case so that instead of failing
> >>> we perform the old capable check in that case.  That seems the mot
> >>> certain way to avoid regressions.  With that said, why is exit_code
> >>> behind a ptrace_may_access permission check?
> >>
> >> Yes, this would be great! And as to @exit_code I think better ask
> >> Kees, CC'ed.
> >
> > My concern was that this was an exposure in the sense that it is
> > internal program state that isn't visible through other means (without
> > being the parent, for example). Under the ptrace check, it has an
> > equivalency that seemed correct at the time.
> >
> > As already covered, I'd agree: it looks like ce99dd5fd5f6 accidentally
> > added a dependency on task->mm where it didn't before. That section of
> > logic was entirely around dumpability, not an mm existing. It should
> > be "EPERM if mm and dumpable != SUID_DUMP_USER".
> >
> > That said, I'd also agree that ptrace against no mm is crazy (though I
> > suppose that should return EINVAL or ESRCH or something), so perhaps a
> > better access control on @exit_code is needed here.
> 
> I traced down the original logic of why we had that dumpable
> variable, and it was ancient conservative on my part when we started
> using the ptrace permission checks for proc files.
> 
> That same conservatism has resulted in the regression under
> discussion.
> 
> Given that we already have a very full set of permission checks
> separate from dumpable in ptrace_may_access I think it makes sense
> to simply ignore dumpable when there is no mm.
> AKA:
> 	mm = task->mm;
> 	if (mm &&
> 	    ((get_dumpable(mm) != SUID_DUMP_USER) &&
> 	     !ptrace_has_cap(mm->user_ns, mode)))
> 	    return -EPERM;
> 
> Because while it has been used for other things dumpable is
> fundamentally about do you have permission to read the mm.
> So there is no real point in permission checks that protect
> the mm if the mm has gone away.
> 
> It also looks like I may need to update the check that sets
> PT_PTRACE_CAP to look at mm->user_ns as well.

Thanks a lot for informative explanations, Eric and Kees!
Eric, if you make some patch please ping me to test it.

  reply	other threads:[~2016-10-25  9:02 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-24 10:59 [ISSUE] mm: Add a user_ns owner to mm_struct and fix ptrace_may_access Cyrill Gorcunov
2016-10-24 19:00 ` Andrey Vagin
     [not found] ` <20161024105959.GQ1847-ZmlpmtaulQd+urZeOPWqwQ@public.gmane.org>
2016-10-24 19:01   ` Eric W. Biederman
2016-10-24 19:01     ` Eric W. Biederman
2016-10-24 20:29     ` Cyrill Gorcunov
     [not found]       ` <20161024202925.GS1847-ZmlpmtaulQd+urZeOPWqwQ@public.gmane.org>
2016-10-24 21:32         ` Kees Cook
2016-10-24 21:32           ` Kees Cook
2016-10-24 23:11           ` Eric W. Biederman
2016-10-25  9:02             ` Cyrill Gorcunov [this message]
2016-10-27 15:54               ` [REVIEW][PATCH v2] mm: Add a user_ns owner to mm_struct and fix ptrace permission checks Eric W. Biederman
2016-10-27 21:27                 ` Kees Cook
     [not found]                 ` <87d1ilrdmt.fsf_-_-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2016-10-27 21:27                   ` Kees Cook
2016-10-27 21:39                   ` Cyrill Gorcunov
2016-10-27 21:39                 ` Cyrill Gorcunov
2016-10-27 22:34                   ` Cyrill Gorcunov
     [not found]                     ` <20161027223430.GC1922-ZmlpmtaulQd+urZeOPWqwQ@public.gmane.org>
2016-10-28  2:22                       ` Eric W. Biederman
2016-10-28  2:22                         ` Eric W. Biederman
     [not found]                         ` <8760odnrf5.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2016-10-28  4:45                           ` Eric W. Biederman
2016-10-28  4:45                             ` Eric W. Biederman
     [not found]                             ` <87pomlm68e.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2016-10-28  7:06                               ` Cyrill Gorcunov
2016-10-28  7:06                             ` Cyrill Gorcunov
     [not found]                   ` <20161027213918.GA1922-ZmlpmtaulQd+urZeOPWqwQ@public.gmane.org>
2016-10-27 22:34                     ` Cyrill Gorcunov
     [not found]               ` <20161025090213.GX1847-ZmlpmtaulQd+urZeOPWqwQ@public.gmane.org>
2016-10-27 15:54                 ` Eric W. Biederman
     [not found]             ` <8760oh737b.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2016-10-25  9:02               ` [ISSUE] mm: Add a user_ns owner to mm_struct and fix ptrace_may_access Cyrill Gorcunov
     [not found]           ` <CAGXu5jK4p4bbQU1Bu-p9aM1GJ+CAR-FAHZcXXRH0De_M4VQ3wA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-10-24 23:11             ` Eric W. Biederman
     [not found]     ` <8760oh8tbp.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2016-10-24 20:29       ` Cyrill Gorcunov

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=20161025090213.GX1847@uranus.lan \
    --to=gorcunov@gmail.com \
    --cc=avagin@virtuozzo.com \
    --cc=containers@lists.linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xemul@virtuozzo.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.