From: Kees Cook <keescook@chromium.org>
To: Dave Chinner <david@fromorbit.com>
Cc: Jan Kara <jack@suse.cz>, "Theodore Ts'o" <tytso@mit.edu>,
Andy Lutomirski <luto@amacapital.net>,
Theodore Tso <tytso@google.com>, Willy Tarreau <w@1wt.eu>,
Dirk Steinmetz <public@rsjtdrjgfuzkfg.com>,
Michael Kerrisk-manpages <mtk.manpages@gmail.com>,
Serge Hallyn <serge.hallyn@ubuntu.com>,
Seth Forshee <seth.forshee@canonical.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Linux FS Devel <linux-fsdevel@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
"Eric W . Biederman" <ebiederm@xmission.com>,
Serge Hallyn <serge.hallyn@canonical.com>,
"security@kernel.org" <security@kernel.org>
Subject: Re: [RFC] namei: prevent sgid-hardlinks for unmapped gids
Date: Thu, 19 Nov 2015 16:11:03 -0800 [thread overview]
Message-ID: <CAGXu5jKBN4E8uy0=_dYyddiZ8ogxS3pO2vF2nuFW57Lmo_x1MA@mail.gmail.com> (raw)
In-Reply-To: <20151119220241.GD19199@dastard>
On Thu, Nov 19, 2015 at 2:02 PM, Dave Chinner <david@fromorbit.com> wrote:
> On Thu, Nov 19, 2015 at 12:11:11PM -0800, Kees Cook wrote:
>> On Tue, Nov 10, 2015 at 7:08 AM, Jan Kara <jack@suse.cz> wrote:
>> > On Sat 07-11-15 21:02:06, Ted Tso wrote:
>> >> On Fri, Nov 06, 2015 at 09:05:57PM -0800, Kees Cook wrote:
>> >> > >>>> They're certainly not used early enough -- we need to remove suid when
>> >> > >>>> the page becomes writable via mmap (wp_page_shared), not when
>> >> > >>>> writeback happens, or at least not only when writeback happens.
>> >> > >>>
>> >> > >>> Well, I'm shy about the change there. For example, we don't strip in
>> >> > >>> on open(RDWR), just on write().
>> >> > >>
>> >> > >> I take it back. Hooking wp_page_shared looks expensive. :) Maybe we do
>> >> > >> need to hook the mmap?
>> >> > >
>> >> > > But file_update_time already pokes at the same (or nearby) cachelines,
>> >> > > I think -- why would it be expensive? The whole thing could be
>> >> > > guarded by if (unlikely(is setuid)), right?
>> >> >
>> >> > Yeah, true. I added file_remove_privs calls near all the
>> >> > file_update_time calls, to no effect. Added to wp_page_shared too,
>> >> > nothing. Hmmm.
>> >>
>> >> Why not put the the should_remove_suid() call in
>> >> filemap_page_mkwrite(), or maybe do_page_mkwrite()?
>> >
>> > page_mkwrite() callbacks are IMHO the right place for this check (and
>> > change). Just next to file_update_time() call. You get proper filesystem
>>
>> Should file_update_time() just be modified to include
>> file_remove_privs()? They seem to regularly go together.
>
> They might have similar call sites, but they are completely
> different operations. timestamp updates are optional, highly
> configurable and behaviour is filesystem implementation specific,
> whilst file_remove_privs() is mandatory and must be done in a
> crash-safe manner (i.e. via transactions). Hence, IMO, they need to
> be kept separate even if the call sites are similar.
Yeah, that was my worry too.
Okay, I think I've got it now. I had misunderstood the purpose of the
page_mkwrite variable in wp_page_reuse. My tests pass now. Patch on
it's way...
-Kees
>
> Cheers,
>
> Dave.
> --
> Dave Chinner
> david@fromorbit.com
--
Kees Cook
Chrome OS Security
next prev parent reply other threads:[~2015-11-20 0:11 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-10 14:59 [PATCH] namei: permit linking with CAP_FOWNER in userns Dirk Steinmetz
2015-10-20 14:09 ` Dirk Steinmetz
2015-10-27 14:33 ` Seth Forshee
2015-10-27 18:08 ` Dirk Steinmetz
2015-10-27 20:28 ` Serge Hallyn
2015-10-28 15:07 ` Dirk Steinmetz
2015-10-28 17:33 ` Serge Hallyn
2015-11-02 15:10 ` Dirk Steinmetz
2015-11-02 18:02 ` Serge Hallyn
2015-11-02 19:57 ` Andy Lutomirski
2015-11-03 0:39 ` [RFC] namei: prevent sgid-hardlinks for unmapped gids Dirk Steinmetz
2015-11-03 15:44 ` Serge Hallyn
2015-11-03 18:20 ` Kees Cook
2015-11-03 23:21 ` Dirk Steinmetz
2015-11-03 23:29 ` Kees Cook
2015-11-04 6:58 ` Willy Tarreau
2015-11-04 17:59 ` Andy Lutomirski
2015-11-04 18:15 ` Willy Tarreau
2015-11-04 18:17 ` Andy Lutomirski
2015-11-04 18:28 ` Willy Tarreau
2015-11-06 21:59 ` Kees Cook
2015-11-06 22:30 ` Andy Lutomirski
2015-11-07 0:11 ` Kees Cook
2015-11-07 0:16 ` Kees Cook
2015-11-07 0:48 ` Andy Lutomirski
2015-11-07 5:05 ` Kees Cook
2015-11-08 2:02 ` Theodore Ts'o
2015-11-10 15:08 ` Jan Kara
2015-11-19 20:11 ` Kees Cook
2015-11-19 21:57 ` Andy Lutomirski
2015-11-19 22:02 ` Dave Chinner
2015-11-20 0:11 ` Kees Cook [this message]
2015-11-04 14:46 ` Serge E. Hallyn
2015-10-27 21:04 ` [PATCH] namei: permit linking with CAP_FOWNER in userns Eric W. Biederman
2015-11-03 17:51 ` Kees Cook
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='CAGXu5jKBN4E8uy0=_dYyddiZ8ogxS3pO2vF2nuFW57Lmo_x1MA@mail.gmail.com' \
--to=keescook@chromium.org \
--cc=david@fromorbit.com \
--cc=ebiederm@xmission.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mtk.manpages@gmail.com \
--cc=public@rsjtdrjgfuzkfg.com \
--cc=security@kernel.org \
--cc=serge.hallyn@canonical.com \
--cc=serge.hallyn@ubuntu.com \
--cc=seth.forshee@canonical.com \
--cc=tytso@google.com \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
--cc=w@1wt.eu \
/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).