linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Djalal Harouni <tixxdz@opendz.org>
To: Kees Cook <keescook@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Ingo Molnar <mingo@kernel.org>, Oleg Nesterov <oleg@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Andy Lutomirski <luto@amacapital.net>,
	LKML <linux-kernel@vger.kernel.org>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH 1/9] procfs: use flags to deny or allow access to /proc/<pid>/$entry
Date: Wed, 28 May 2014 20:11:26 +0100	[thread overview]
Message-ID: <20140528191126.GA3722@dztty> (raw)
In-Reply-To: <CAGXu5jLtinFUuXr2UN0k3BvM5ge4_DfhfKVb8v2SLTbnsMPnOQ@mail.gmail.com>

On Wed, May 28, 2014 at 09:59:54AM -0700, Kees Cook wrote:
> On Wed, May 28, 2014 at 4:42 AM, Djalal Harouni <tixxdz@opendz.org> wrote:
> > On Tue, May 27, 2014 at 11:38:54AM -0700, Kees Cook wrote:
> >> On Mon, May 26, 2014 at 6:27 AM, Djalal Harouni <tixxdz@opendz.org> wrote:
> >> > Add the deny or allow flags, so we can perform proper permission checks
> >> > and set the result accordingly. These flags are needed in case we have
> >> > to cache the result of permission checks that are done during ->open()
> >> > time. Later during ->read(), we can decide to allow or deny the read().
> >> >
> >> > The pid entries that need these flags are:
> >> > /proc/<pid>/stat
> >> > /proc/<pid>/wchan
> >> > /proc/<pid>/maps  (will be handled in next patches).
> >> >
> >> > These files are world readable, userspace depend on that. To prevent
> >> > ASLR leaks and to avoid breaking userspace, we follow this scheme:
> >> >
> >> > a) Perform permission checks during ->open()
> >> > b) Cache the result of a) and return success
> >> > c) Recheck the cached result during ->read()
> >> > d) If cached == PID_ENTRY_DENY:
> >> >    then we replace the sensitive fields with zeros, userspace won't
> >> >    break and sensitive fields are protected.
> >> >
> >> > These flags are internal to /proc/<pid>/*
> >>
> >> Since this complex area of behavior has seen a lot of changes, I think
> >> I'd really like to see some tests in tools/testsing/selftests/
> >> somewhere that actually codify what the expected behaviors should be.
> > Ok, sounds good!
> >
> >> We have a lot of corner cases, a lot of userspace behaviors to retain,
> >> and given how fragile this area has been, I'd love to avoid seeing
> >> regressions. It seems like we need to test file permissions, open/read
> >> permissions, contents, etc, under many different cases (priv, unpriv,
> >> passing between priv/unpriv and unpriv/priv, ptrace checks, etc).
> > Yes, nice.
> >
> >> If we could do a "make run_tests" in a selftests subdirectory, it'd be
> >> much easier to a) validate these fixes, and b) avoid regressions.
> > Ok!
> >
> > Since I'm working on this on my free time and when time permits, please
> > give me some days! I'll try to handle the cases I've discussed here.
> >
> > Now Kees, some of these files are still world readable and affected:
> > smaps, maps ... I know, it's a matter of suid binary on your distro, and
> > every one can exploit it. So what to do: make the tests public or write
> > the tests and fix these entries then at last make the tests public ?
> 
> I expect these tests to be public -- there is nothing secret about how
> things are currently vulnerable. I think the priv vs unpriv tests can
> be emulated (without root setuid) using a prctl(PR_SET_DUMPABLE, 0)
> call which should give you similar protections.
Ok, thanks for the hint!

> > Where should I send the tests ?
> 
> They should be part of the patch series, and live in the
> tools/testing/selftests/ tree of the kernel. There are plenty of
> examples in there. If you have the tests as the first set of patches,
> then you can show which tests start passing with each additional fix.
> I would break the tests up into "what is expected to work now" that
> all pass, and then add all the cases that are currently a problem that
> will all fail. Then as more of the fixes land from your series, more
> of those tests will pass until everything is passing.
Ok, will follow and do that. Thank you Kees!

> 
> -- 
> Kees Cook
> Chrome OS Security

-- 
Djalal Harouni
http://opendz.org

  reply	other threads:[~2014-05-28 19:11 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-26 13:27 [PATCH 0/9] procfs: smooth steps to secure some /proc/<pid>/* Djalal Harouni
2014-05-26 13:27 ` [PATCH 1/9] procfs: use flags to deny or allow access to /proc/<pid>/$entry Djalal Harouni
2014-05-26 16:57   ` Andy Lutomirski
2014-05-26 17:21     ` Djalal Harouni
2014-05-26 18:06       ` Andy Lutomirski
2014-05-26 19:13         ` Djalal Harouni
2014-05-26 19:17           ` Andy Lutomirski
2014-05-27 13:42             ` Djalal Harouni
2014-05-27 18:38   ` Kees Cook
2014-05-28 11:42     ` Djalal Harouni
2014-05-28 16:59       ` Kees Cook
2014-05-28 19:11         ` Djalal Harouni [this message]
2014-05-26 13:27 ` [PATCH 2/9] procfs: add pid_entry_access() for proper checks on /proc/<pid>/* Djalal Harouni
2014-05-26 16:57   ` Andy Lutomirski
2014-05-26 13:27 ` [PATCH 3/9] procfs: add proc_read_from_buffer() and pid_entry_read() helpers Djalal Harouni
2014-05-26 17:01   ` Andy Lutomirski
2014-05-26 17:41     ` Djalal Harouni
2014-05-26 17:59       ` Andy Lutomirski
2014-05-26 18:21         ` Djalal Harouni
2014-05-26 18:44           ` Djalal Harouni
2014-06-03 10:13   ` Alexey Dobriyan
2014-05-26 13:27 ` [PATCH 4/9] procfs: improve /proc/<pid>/wchan protection Djalal Harouni
2014-05-26 13:27 ` [PATCH 5/9] procfs: improve /proc/<pid>/syscall protection Djalal Harouni
2014-05-26 13:27 ` [PATCH 6/9] procfs: add pid_seq_private struct to handle /proc/<pid>/{stat|stack} Djalal Harouni
2014-05-26 17:02   ` Andy Lutomirski
2014-05-27 11:18     ` Djalal Harouni
2014-05-26 13:27 ` [PATCH 7/9] procfs: add pid_entry_show() helper " Djalal Harouni
2014-05-26 13:27 ` [PATCH 8/9] procfs: improve /proc/<pid>/stat protection Djalal Harouni
2014-05-26 13:27 ` [PATCH 9/9] procfs: improve /proc/<pid>/stack protection Djalal Harouni

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=20140528191126.GA3722@dztty \
    --to=tixxdz@opendz.org \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=keescook@chromium.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /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).