All of lore.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Vivek Goyal <vgoyal@redhat.com>
Cc: linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Amir Goldstein <amir73il@gmail.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	James Bottomley <James.Bottomley@HansenPartnership.com>,
	Miklos Szeredi <miklos@szeredi.hu>
Subject: Re: [PATCH][V2] vfs: Use upper filesystem inode in bprm_fill_uid()
Date: Tue, 14 Feb 2017 20:52:40 +1300	[thread overview]
Message-ID: <87fujhmcon.fsf@xmission.com> (raw)
In-Reply-To: <20170213204526.GG2065@redhat.com> (Vivek Goyal's message of "Mon, 13 Feb 2017 15:45:26 -0500")

Vivek Goyal <vgoyal@redhat.com> writes:

> 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.
>  
> Signed-off-by: Vivek Goyal <vgoyal@redhat.com>

Applied thanks,

Eric

> ---
>  fs/exec.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> Index: rhvgoyal-linux/fs/exec.c
> ===================================================================
> --- rhvgoyal-linux.orig/fs/exec.c	2017-02-13 15:22:57.107114781 -0500
> +++ rhvgoyal-linux/fs/exec.c	2017-02-13 15:24:19.568114781 -0500
> @@ -1479,7 +1479,7 @@ static void bprm_fill_uid(struct linux_b
>  	if (task_no_new_privs(current))
>  		return;
>  
> -	inode = file_inode(bprm->file);
> +	inode = bprm->file->f_path.dentry->d_inode;
>  	mode = READ_ONCE(inode->i_mode);
>  	if (!(mode & (S_ISUID|S_ISGID)))
>  		return;

      reply	other threads:[~2017-02-14  7:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-13 20:45 [PATCH][V2] vfs: Use upper filesystem inode in bprm_fill_uid() Vivek Goyal
2017-02-14  7:52 ` Eric W. Biederman [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=87fujhmcon.fsf@xmission.com \
    --to=ebiederm@xmission.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=amir73il@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=vgoyal@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.