From: Vivek Goyal <vgoyal@redhat.com>
To: Amir Goldstein <amir73il@gmail.com>
Cc: linux-fsdevel <linux-fsdevel@vger.kernel.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Al Viro <viro@zeniv.linux.org.uk>,
James Bottomley <James.Bottomley@hansenpartnership.com>,
Miklos Szeredi <mszeredi@redhat.com>
Subject: Re: [PATCH] vfs: Use upper filesystem inode in bprm_fill_uid()
Date: Mon, 13 Feb 2017 15:38:20 -0500 [thread overview]
Message-ID: <20170213203820.GF2065@redhat.com> (raw)
In-Reply-To: <CAOQ4uxieVT67sWmSeruAGDAAhaq1ayT0LoCDRAZZGSLG6gsyXw@mail.gmail.com>
On Mon, Feb 13, 2017 at 10:01:09PM +0200, Amir Goldstein wrote:
> On Mon, Feb 13, 2017 at 9:06 PM, Vivek Goyal <vgoyal@redhat.com> wrote:
> > On Mon, Feb 13, 2017 at 08:07:16PM +0200, Amir Goldstein wrote:
> >> On Mon, Feb 13, 2017 at 6:18 PM, Vivek Goyal <vgoyal@redhat.com> wrote:
> >> > Right now bprm_fill_uid() uses inode fetched from file_inode(bprm->file).
> >> > This in turn returns inode of lower filesystem (in a stacked filesystem
> >> > setup).
> >> >
> >> > I was playing with modified patches of shiftfs posted by james bottomley
> >> > and realized that through shiftfs setuid bit does not take effect. And
> >> > reason being that we fetch uid/gid from inode of lower fs (and not from
> >> > shiftfs inode). And that results in following checks failing.
> >> >
> >> > /* We ignore suid/sgid if there are no mappings for them in the ns */
> >> > if (!kuid_has_mapping(bprm->cred->user_ns, uid) ||
> >> > !kgid_has_mapping(bprm->cred->user_ns, gid))
> >> > return;
> >> >
> >> > uid/gid fetched from lower fs inode might not be mapped inside the user
> >> > namespace of container. So we need to look at uid/gid fetched from
> >> > upper filesystem (shiftfs in this particular case) and these should be
> >> > mapped and setuid bit can take affect.
> >>
> >> This change is consistent with may_linkat() -> safe_hardlink_source()
> >> and with all instances of notify_change() in fs/open.c, but is not
> >> consistent with file_remove_privs() -> ...
> >> should_remove_suid()/notify_change()
> >> which also uses file_inode()
> >
> > I did a quick grep to figure out who is calling file_remove_privs(). Looks
> > like it is being called by underlying filesystem (ext4, xfs, ntfs, fuse).
> > If that's the case, we probably want to use the dentry and inode of
> > underlying filesystem and not recurse back to top level filesystem?
> >
>
> No I think you are right and there is no problem with file_remove_privs().
>
> Not sure about do_coredump(), though, which uses file_inode(cprm.file).
> Other places in vfs that check inode->i_uid are even harder to follow.
Hmm.., file_inode(cprm.file) might be a problem too with shiftfs. For
now I will post V2 of this patch and follow this core dump issue
separately.
Vivek
prev parent reply other threads:[~2017-02-13 20:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-13 16:18 [PATCH] vfs: Use upper filesystem inode in bprm_fill_uid() Vivek Goyal
2017-02-13 18:07 ` Amir Goldstein
2017-02-13 19:06 ` Vivek Goyal
2017-02-13 20:01 ` Amir Goldstein
2017-02-13 20:38 ` Vivek Goyal [this message]
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=20170213203820.GF2065@redhat.com \
--to=vgoyal@redhat.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=amir73il@gmail.com \
--cc=ebiederm@xmission.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=mszeredi@redhat.com \
--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 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.