Coly Li 9c546c
From bbc3e471011417598e598707486f5d8814ec9c01 Mon Sep 17 00:00:00 2001
Coly Li 9c546c
From: "Eric W. Biederman" <ebiederm@xmission.com>
Coly Li 9c546c
Date: Wed, 29 Nov 2017 17:29:20 -0600
Coly Li 9c546c
Subject: [PATCH] userns: Don't fail follow_automount based on s_user_ns
Coly Li 9c546c
Git-commit: bbc3e471011417598e598707486f5d8814ec9c01
Coly Li 9c546c
Patch-mainline: v4.16-rc1
Coly Li 9c546c
References: bsc#1099918
Coly Li 9c546c
Coly Li 9c546c
When vfs_submount was added the test to limit automounts from
Coly Li 9c546c
filesystems that with s_user_ns != &init_user_ns accidentially left
Coly Li 9c546c
in follow_automount.  The test was never about any security concerns
Coly Li 9c546c
and was always about how do we implement this for filesystems whose
Coly Li 9c546c
s_user_ns != &init_user_ns.
Coly Li 9c546c
Coly Li 9c546c
At the moment this check makes no difference as there are no
Coly Li 9c546c
filesystems that both set FS_USERNS_MOUNT and implement d_automount.
Coly Li 9c546c
Coly Li 9c546c
Remove this check now while I am thinking about it so there will not
Coly Li 9c546c
be odd booby traps for someone who does want to make this combination
Coly Li 9c546c
work.
Coly Li 9c546c
Coly Li 9c546c
vfs_submount still needs improvements to allow this combination to work,
Coly Li 9c546c
and vfs_submount contains a check that presents a warning.
Coly Li 9c546c
Coly Li 9c546c
The autofs4 filesystem could be modified to set FS_USERNS_MOUNT and it would
Coly Li 9c546c
need not work on this code path, as userspace performs the mounts.
Coly Li 9c546c
Coly Li 9c546c
Fixes: 93faccbbfa95 ("fs: Better permission checking for submounts")
Coly Li 9c546c
Fixes: aeaa4a79ff6a ("fs: Call d_automount with the filesystems creds")
Coly Li 9c546c
Acked-by: Ian Kent <raven@themaw.net>
Coly Li 9c546c
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Coly Li 9c546c
Signed-off-by: Coly Li <colyli@suse.de>
Coly Li 9c546c
Coly Li 9c546c
---
Coly Li 9c546c
 fs/namei.c |    3 ---
Coly Li 9c546c
 1 file changed, 3 deletions(-)
Coly Li 9c546c
Coly Li 9c546c
--- a/fs/namei.c
Coly Li 9c546c
+++ b/fs/namei.c
Coly Li 9c546c
@@ -1133,9 +1133,6 @@ static int follow_automount(struct path
Coly Li 9c546c
 	    path->dentry->d_inode)
Coly Li 9c546c
 		return -EISDIR;
Coly Li 9c546c
 
Coly Li 9c546c
-	if (path->dentry->d_sb->s_user_ns != &init_user_ns)
Coly Li 9c546c
-		return -EACCES;
Coly Li 9c546c
-
Coly Li 9c546c
 	nd->total_link_count++;
Coly Li 9c546c
 	if (nd->total_link_count >= 40)
Coly Li 9c546c
 		return -ELOOP;