From: Dave Chinner <david@fromorbit.com>
To: Andrew Lutomirski <andy@luto.us>
Cc: Kenton Varda <kenton@sandstorm.io>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Drew Fisher <drew@sandstorm.io>,
David Renshaw <david@sandstorm.io>,
linux-fsdevel@vger.kernel.org
Subject: Re: bind mount that lies to apps about st_uid?
Date: Wed, 15 Jul 2015 10:53:30 +1000 [thread overview]
Message-ID: <20150715005330.GS3902@dastard> (raw)
In-Reply-To: <CAObL_7Hu88g1cq8ZL6eQ4s6eafm3p7dX0ChjjCsVq400dDJNRA@mail.gmail.com>
On Tue, Jul 14, 2015 at 05:41:01PM -0700, Andrew Lutomirski wrote:
> On Tue, Jul 14, 2015 at 5:35 PM, Kenton Varda <kenton@sandstorm.io> wrote:
> > Hi Eric,
> >
> > I'm curious to know if you think this the following is something that could
> > realistically be implemented, or if it's a totally outrageous idea. :)
> >
> > For Sandstorm, we've found a case where it would be useful if we could
> > create a bind-mount in which stat() calls lie and claim all files have UID
> > 65534 (as if their real owner wasn't mapped into the user namespace). All
> > actual security checks would behave normally; only the result of stat()
> > would be affected.
> >
> > Specifically, the problem is that some apps have checks of the form: "If
> > file is owned by my UID, then modify it, otherwise do something else
> > reasonable." These checks are wrong in the case of read-only bind mounts,
> > but legacy code rarely considers such a possibility.
> >
> > Making maters worse, it is the case currently that some configurations of
> > Sandstorm will have these read-only files owned by the UID running the app
> > while others will not. Thus this is an observable difference between servers
> > that can affect app behavior, causing them to work fine on some servers but
> > break on others, which is something we want to avoid at all costs. We can't
> > see any reasonable way to resolve the difference without kernel help,
> > unfortunately.
> >
> > So, it would be convenient if I could trick these apps into behaving
> > correctly by asking the kernel to lie to them about the UID. For our use
> > case, a boolean flag would work. It could simply say: "For stat() purposes
> > on this mount, act as if the uid_map and gid_map are empty, therefore return
> > st_uid and st_gid as 65534." Alternatively, I'd also be happy with a "uid="
> > setting that overrides all reported UIDs, which seems possibly more broadly
> > useful, but also possibly riskier(?). I'm also happy with restricting this
> > to only mounts with MS_RDONLY and MS_NOSUID, if that helps.
> >
> > It's a hack, but it's simple and would save a bunch of confusion for our
> > developers in the long run, I think.
Why wouldn't you just use an ld preload library to intercept stat()
calls in userspace and manipulate them there? No kernel changes
required, no app changes required....
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2015-07-15 0:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAOP=4wipj4u_hpXRMh4qWn=ofb-br_=qS8vY8-WjqUrphQNw4w@mail.gmail.com>
2015-07-15 0:41 ` bind mount that lies to apps about st_uid? Andrew Lutomirski
2015-07-15 0:53 ` Dave Chinner [this message]
2015-07-15 1:14 ` Kenton Varda
2015-07-15 1:24 ` Andrew Lutomirski
2015-07-15 1:40 ` Kenton Varda
2015-07-16 17:59 ` Kees Cook
2015-07-15 1:12 ` Eric W. Biederman
2015-07-15 1:27 ` Kenton Varda
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=20150715005330.GS3902@dastard \
--to=david@fromorbit.com \
--cc=andy@luto.us \
--cc=david@sandstorm.io \
--cc=drew@sandstorm.io \
--cc=ebiederm@xmission.com \
--cc=kenton@sandstorm.io \
--cc=linux-fsdevel@vger.kernel.org \
/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.