linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Serge Hallyn <serge.hallyn@ubuntu.com>
To: Seth Forshee <seth.forshee@canonical.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	fuse-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v3 2/4] vfs,userns: Ensure real root is always capable towards inodes
Date: Fri, 12 Sep 2014 17:13:05 +0000	[thread overview]
Message-ID: <20140912171305.GI26117@ubuntumail> (raw)
In-Reply-To: <1410532905-114262-3-git-send-email-seth.forshee@canonical.com>

Quoting Seth Forshee (seth.forshee@canonical.com):
> Currently root is restricted from performing some modifications
> to inodes whose owner is INVALID_UID or group is INVALID_GID
> because this id doesn't map into any user namespace. Add a
> special case to the relevant checks to make sure root is always
> capable of performing these operations.
> 
> Signed-off-by: Seth Forshee <seth.forshee@canonical.com>

(A case which was previously not possible.)

Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>

> ---
>  fs/inode.c          | 3 +++
>  kernel/capability.c | 6 +++++-
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/inode.c b/fs/inode.c
> index 26753ba7b6d6..1029320ff029 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -1840,6 +1840,9 @@ bool inode_owner_or_capable(const struct inode *inode)
>  {
>  	struct user_namespace *ns;
>  
> +	if (capable(CAP_SYS_ADMIN))
> +		return true;
> +
>  	if (uid_eq(current_fsuid(), inode->i_uid))
>  		return true;
>  
> diff --git a/kernel/capability.c b/kernel/capability.c
> index 989f5bfc57dc..a472eaa52b6a 100644
> --- a/kernel/capability.c
> +++ b/kernel/capability.c
> @@ -438,8 +438,12 @@ EXPORT_SYMBOL(capable);
>   */
>  bool capable_wrt_inode_uidgid(const struct inode *inode, int cap)
>  {
> -	struct user_namespace *ns = current_user_ns();
> +	struct user_namespace *ns;
>  
> +	if (capable(CAP_SYS_ADMIN))
> +		return true;
> +
> +	ns = current_user_ns();
>  	return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid) &&
>  		kgid_has_mapping(ns, inode->i_gid);
>  }
> -- 
> 1.9.1
> 

  reply	other threads:[~2014-09-12 17:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-12 14:41 [PATCH v3 0/4] fuse: Add support for mounts from pid/user namespaces Seth Forshee
     [not found] ` <1410532905-114262-1-git-send-email-seth.forshee-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2014-09-12 14:41   ` [PATCH v3 1/4] vfs: Check for invalid i_uid in may_follow_link() Seth Forshee
2014-09-12 14:41   ` [PATCH v3 2/4] vfs, userns: Ensure real root is always capable towards inodes Seth Forshee
2014-09-12 17:13     ` Serge Hallyn [this message]
2014-09-12 14:41   ` [PATCH v3 3/4] fuse: Translate pids passed to userspace into pid namespaces Seth Forshee
2014-09-12 14:41   ` [PATCH v3 4/4] fuse: Add support for mounts from user namespaces Seth Forshee
2014-09-23 14:28 ` [PATCH v3 0/4] fuse: Add support for mounts from pid/user namespaces Seth Forshee
2014-09-23 17:08   ` Serge E. Hallyn

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=20140912171305.GI26117@ubuntumail \
    --to=serge.hallyn@ubuntu.com \
    --cc=ebiederm@xmission.com \
    --cc=fuse-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=seth.forshee@canonical.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 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).