From mboxrd@z Thu Jan 1 00:00:00 1970 From: Seth Forshee Subject: [PATCH v4 3/5] fuse: Restrict allow_other to uids already controlled by the user Date: Tue, 14 Oct 2014 16:25:54 +0200 Message-ID: <1413296756-25071-4-git-send-email-seth.forshee@canonical.com> References: <1413296756-25071-1-git-send-email-seth.forshee@canonical.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: fuse-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, "Serge H. Hallyn" , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Seth Forshee , "Eric W. Biederman" , linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Miklos Szeredi Return-path: In-Reply-To: <1413296756-25071-1-git-send-email-seth.forshee-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fuse-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: linux-fsdevel.vger.kernel.org Unprivileged users are normally restricted from mounting with the allow_other option by system policy, but this could be bypassed for a mount done with user namespace root permissions. In such cases allow_other should not allow users outside the user namespace to access the mount as doing so would give the unprivileged user the ability to manipulate processes it would otherwise be unable to manipulate. Cc: Eric W. Biederman Cc: Serge H. Hallyn Signed-off-by: Seth Forshee --- fs/fuse/dir.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 123db1e06c78..e3123bfbc711 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -1089,12 +1089,20 @@ int fuse_reverse_inval_entry(struct super_block *sb, u64 parent_nodeid, */ int fuse_allow_current_process(struct fuse_conn *fc) { - const struct cred *cred; + const struct cred *cred = current_cred(); - if (fc->flags & FUSE_ALLOW_OTHER) - return 1; + if (fc->flags & FUSE_ALLOW_OTHER) { + if (kuid_has_mapping(fc->user_ns, cred->euid) && + kuid_has_mapping(fc->user_ns, cred->suid) && + kuid_has_mapping(fc->user_ns, cred->uid) && + kgid_has_mapping(fc->user_ns, cred->egid) && + kgid_has_mapping(fc->user_ns, cred->sgid) && + kgid_has_mapping(fc->user_ns, cred->gid)) + return 1; + + return 0; + } - cred = current_cred(); if (uid_eq(cred->euid, fc->user_id) && uid_eq(cred->suid, fc->user_id) && uid_eq(cred->uid, fc->user_id) && -- 2.1.0 ------------------------------------------------------------------------------ Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho