Skip to contentSkip to conversation

fuse: Ensure posix acls are translated outside of init_user_ns

PATCH In review Eric W. Biederman 8 participants 14 messages May 4, 2018 – May 31, 2018 5 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fuse: Ensure posix acls are translated outside of init_user_ns

Ensure the translation happens by failing to read or write posix acls when the filesystem has not indicated it supports posix acls.

This ensures that modern cached posix acl support is available and used when dealing with posix acls. This is important because only that path has the code to convernt the uids and gids in posix acls into the user namespace of a fuse filesystem.

---

Miklos after several attempts to handle this better last cycle. I figure we should go with the stupid version for now. I think I know how to do better but I don't want that to gate forward progress on fully unprivileged fuse mounts. Especially as this is the last known issue to deal with.

 fs/fuse/fuse_i.h |  1 +
 fs/fuse/inode.c  |  7 +++++++
 fs/fuse/xattr.c  | 43 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+)
fs/fuse/fuse_i.h +1 -0
index f630951df8dc..5256ad333b05 100644
@@ -985,6 +985,7 @@ ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size);
 int fuse_removexattr(struct inode *inode, const char *name);
 extern const struct xattr_handler *fuse_xattr_handlers[];
 extern const struct xattr_handler *fuse_acl_xattr_handlers[];
+extern const struct xattr_handler *fuse_no_acl_xattr_handlers[];
 
 struct posix_acl;
 struct posix_acl *fuse_get_acl(struct inode *inode, int type);
fs/fuse/inode.c +7 -0
index 1643043d4fe5..22c76cf8c2e3 100644
@@ -1100,6 +1100,13 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
 	    file->f_cred->user_ns != sb->s_user_ns)
 		goto err_fput;
 
+	/*
+	 * If we are not in the initial user namespace posix
+	 * acls must be translated.
+	 */
+	if (sb->s_user_ns != &init_user_ns)
+		sb->s_xattr = fuse_no_acl_xattr_handlers;
+
 	fc = kmalloc(sizeof(*fc), GFP_KERNEL);
 	err = -ENOMEM;
 	if (!fc)
fs/fuse/xattr.c +43 -0

52 lines not on this page · raw message

Signature · 1 line
2.14.1
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Eric W. Biederman

Ensure the translation happens by failing to read or write posix acls when the filesystem has not indicated it supports posix acls.

This ensures that modern cached posix acl support is available and used when dealing with posix acls. This is important because only that path has the code to convernt the uids and gids in posix acls into the user namespace of a fuse filesystem.

Quoted 8 lines

---

Miklos after several attempts to handle this better last cycle. I figure we should go with the stupid version for now. I think I know how to do better but I don't want that to gate forward progress on fully unprivileged fuse mounts. Especially as this is the last known issue to deal with.

This seems reasonable as a short-term measure.

A message that is not in the archive (sent off-list or not yet received): 87r2mre5b3.fsf-aS9lmoZGLiVWk0Htik3J/[email protected]

Acked-by
#3 lore raw
Quoted 10 lines · Eric W. Biederman

Ensure the translation happens by failing to read or write posix acls when the filesystem has not indicated it supports posix acls.

This ensures that modern cached posix acl support is available and used when dealing with posix acls. This is important because only that path has the code to convernt the uids and gids in posix acls into the user namespace of a fuse filesystem.

Quoted 8 lines

---

Miklos after several attempts to handle this better last cycle. I figure we should go with the stupid version for now. I think I know how to do better but I don't want that to gate forward progress on fully unprivileged fuse mounts. Especially as this is the last known issue to deal with.

This seems reasonable as a short-term measure.

#4 lore raw
In reply to a message not in the archive
Quoted 11 lines · ebiederm-aS9lmoZGLiVWk0Htik3J/[email protected] (Eric W. Biederman) writes:

Ensure the translation happens by failing to read or write posix acls when the filesystem has not indicated it supports posix acls.

This ensures that modern cached posix acl support is available and used when dealing with posix acls. This is important because only that path has the code to convernt the uids and gids in posix acls into the user namespace of a fuse filesystem.

---

ping.

Miklos are you around where you can look at this?

Quoted 99 lines

Miklos after several attempts to handle this better last cycle. I figure we should go with the stupid version for now. I think I know how to do better but I don't want that to gate forward progress on fully unprivileged fuse mounts. Especially as this is the last known issue to deal with.

 fs/fuse/fuse_i.h |  1 +
 fs/fuse/inode.c  |  7 +++++++
 fs/fuse/xattr.c  | 43 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+)
fs/fuse/fuse_i.h +1 -0
index f630951df8dc..5256ad333b05 100644
@@ -985,6 +985,7 @@ ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size);
 int fuse_removexattr(struct inode *inode, const char *name);
 extern const struct xattr_handler *fuse_xattr_handlers[];
 extern const struct xattr_handler *fuse_acl_xattr_handlers[];
+extern const struct xattr_handler *fuse_no_acl_xattr_handlers[];
 
 struct posix_acl;
 struct posix_acl *fuse_get_acl(struct inode *inode, int type);
fs/fuse/inode.c +7 -0
index 1643043d4fe5..22c76cf8c2e3 100644
@@ -1100,6 +1100,13 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
 	    file->f_cred->user_ns != sb->s_user_ns)
 		goto err_fput;
 
+	/*
+	 * If we are not in the initial user namespace posix
+	 * acls must be translated.
+	 */
+	if (sb->s_user_ns != &init_user_ns)
+		sb->s_xattr = fuse_no_acl_xattr_handlers;
+
 	fc = kmalloc(sizeof(*fc), GFP_KERNEL);
 	err = -ENOMEM;
 	if (!fc)
fs/fuse/xattr.c +43 -0
index 3caac46b08b0..433717640f78 100644
@@ -192,6 +192,26 @@ static int fuse_xattr_set(const struct xattr_handler *handler,
 	return fuse_setxattr(inode, name, value, size, flags);
 }
 
+static bool no_xattr_list(struct dentry *dentry)
+{
+	return false;
+}
+
+static int no_xattr_get(const struct xattr_handler *handler,
+			struct dentry *dentry, struct inode *inode,
+			const char *name, void *value, size_t size)
+{
+	return -EOPNOTSUPP;
+}
+
+static int no_xattr_set(const struct xattr_handler *handler,
+			struct dentry *dentry, struct inode *nodee,
+			const char *name, const void *value,
+			size_t size, int flags)
+{
+	return -EOPNOTSUPP;
+}
+
 static const struct xattr_handler fuse_xattr_handler = {
 	.prefix = "",
 	.get    = fuse_xattr_get,
@@ -209,3 +229,26 @@ const struct xattr_handler *fuse_acl_xattr_handlers[] = {
 	&fuse_xattr_handler,
 	NULL
 };
+
+static const struct xattr_handler fuse_no_acl_access_xattr_handler = {
+	.name  = XATTR_NAME_POSIX_ACL_ACCESS,
+	.flags = ACL_TYPE_ACCESS,
+	.list  = no_xattr_list,
+	.get   = no_xattr_get,
+	.set   = no_xattr_set,
+};
+
+static const struct xattr_handler fuse_no_acl_default_xattr_handler = {
+	.name  = XATTR_NAME_POSIX_ACL_DEFAULT,
+	.flags = ACL_TYPE_ACCESS,
+	.list  = no_xattr_list,
+	.get   = no_xattr_get,
+	.set   = no_xattr_set,
+};
+
+const struct xattr_handler *fuse_no_acl_xattr_handlers[] = {
+	&fuse_no_acl_access_xattr_handler,
+	&fuse_no_acl_default_xattr_handler,
+	&fuse_xattr_handler,
+	NULL
+};
#5 lore raw
In reply to Eric W. Biederman
Quoted 11 lines · [email protected] (Eric W. Biederman) writes:

Ensure the translation happens by failing to read or write posix acls when the filesystem has not indicated it supports posix acls.

This ensures that modern cached posix acl support is available and used when dealing with posix acls. This is important because only that path has the code to convernt the uids and gids in posix acls into the user namespace of a fuse filesystem.

---

ping.

Miklos are you around where you can look at this?

Quoted 99 lines

Miklos after several attempts to handle this better last cycle. I figure we should go with the stupid version for now. I think I know how to do better but I don't want that to gate forward progress on fully unprivileged fuse mounts. Especially as this is the last known issue to deal with.

 fs/fuse/fuse_i.h |  1 +
 fs/fuse/inode.c  |  7 +++++++
 fs/fuse/xattr.c  | 43 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+)
fs/fuse/fuse_i.h +1 -0
index f630951df8dc..5256ad333b05 100644
@@ -985,6 +985,7 @@ ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size);
 int fuse_removexattr(struct inode *inode, const char *name);
 extern const struct xattr_handler *fuse_xattr_handlers[];
 extern const struct xattr_handler *fuse_acl_xattr_handlers[];
+extern const struct xattr_handler *fuse_no_acl_xattr_handlers[];
 
 struct posix_acl;
 struct posix_acl *fuse_get_acl(struct inode *inode, int type);
fs/fuse/inode.c +7 -0
index 1643043d4fe5..22c76cf8c2e3 100644
@@ -1100,6 +1100,13 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
 	    file->f_cred->user_ns != sb->s_user_ns)
 		goto err_fput;
 
+	/*
+	 * If we are not in the initial user namespace posix
+	 * acls must be translated.
+	 */
+	if (sb->s_user_ns != &init_user_ns)
+		sb->s_xattr = fuse_no_acl_xattr_handlers;
+
 	fc = kmalloc(sizeof(*fc), GFP_KERNEL);
 	err = -ENOMEM;
 	if (!fc)
fs/fuse/xattr.c +43 -0
index 3caac46b08b0..433717640f78 100644
@@ -192,6 +192,26 @@ static int fuse_xattr_set(const struct xattr_handler *handler,
 	return fuse_setxattr(inode, name, value, size, flags);
 }
 
+static bool no_xattr_list(struct dentry *dentry)
+{
+	return false;
+}
+
+static int no_xattr_get(const struct xattr_handler *handler,
+			struct dentry *dentry, struct inode *inode,
+			const char *name, void *value, size_t size)
+{
+	return -EOPNOTSUPP;
+}
+
+static int no_xattr_set(const struct xattr_handler *handler,
+			struct dentry *dentry, struct inode *nodee,
+			const char *name, const void *value,
+			size_t size, int flags)
+{
+	return -EOPNOTSUPP;
+}
+
 static const struct xattr_handler fuse_xattr_handler = {
 	.prefix = "",
 	.get    = fuse_xattr_get,
@@ -209,3 +229,26 @@ const struct xattr_handler *fuse_acl_xattr_handlers[] = {
 	&fuse_xattr_handler,
 	NULL
 };
+
+static const struct xattr_handler fuse_no_acl_access_xattr_handler = {
+	.name  = XATTR_NAME_POSIX_ACL_ACCESS,
+	.flags = ACL_TYPE_ACCESS,
+	.list  = no_xattr_list,
+	.get   = no_xattr_get,
+	.set   = no_xattr_set,
+};
+
+static const struct xattr_handler fuse_no_acl_default_xattr_handler = {
+	.name  = XATTR_NAME_POSIX_ACL_DEFAULT,
+	.flags = ACL_TYPE_ACCESS,
+	.list  = no_xattr_list,
+	.get   = no_xattr_get,
+	.set   = no_xattr_set,
+};
+
+const struct xattr_handler *fuse_no_acl_xattr_handlers[] = {
+	&fuse_no_acl_access_xattr_handler,
+	&fuse_no_acl_default_xattr_handler,
+	&fuse_xattr_handler,
+	NULL
+};

A message that is not in the archive (sent off-list or not yet received): 87wovubbdf.fsf-aS9lmoZGLiVWk0Htik3J/[email protected]

#7 lore raw
Quoted 11 lines · ebiederm-aS9lmoZGLiVWk0Htik3J/[email protected] (Eric W. Biederman) writes:
Quoted 9 lines · ebiederm-aS9lmoZGLiVWk0Htik3J/[email protected] (Eric W. Biederman) writes:

Ensure the translation happens by failing to read or write posix acls when the filesystem has not indicated it supports posix acls.

This ensures that modern cached posix acl support is available and used when dealing with posix acls. This is important because only that path has the code to convernt the uids and gids in posix acls into the user namespace of a fuse filesystem.

Quoted 6 lines
Quoted 2 lines

---

ping.

Miklos are you around where you can look at this?

Perhaps I got the wrong email address.

Ping?

Quoted 100 lines
Quoted 100 lines

Miklos after several attempts to handle this better last cycle. I figure we should go with the stupid version for now. I think I know how to do better but I don't want that to gate forward progress on fully unprivileged fuse mounts. Especially as this is the last known issue to deal with.

 fs/fuse/fuse_i.h |  1 +
 fs/fuse/inode.c  |  7 +++++++
 fs/fuse/xattr.c  | 43 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+)
fs/fuse/fuse_i.h +1 -0
index f630951df8dc..5256ad333b05 100644
@@ -985,6 +985,7 @@ ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size);
 int fuse_removexattr(struct inode *inode, const char *name);
 extern const struct xattr_handler *fuse_xattr_handlers[];
 extern const struct xattr_handler *fuse_acl_xattr_handlers[];
+extern const struct xattr_handler *fuse_no_acl_xattr_handlers[];
 
 struct posix_acl;
 struct posix_acl *fuse_get_acl(struct inode *inode, int type);
fs/fuse/inode.c +7 -0
index 1643043d4fe5..22c76cf8c2e3 100644
@@ -1100,6 +1100,13 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
 	    file->f_cred->user_ns != sb->s_user_ns)
 		goto err_fput;
 
+	/*
+	 * If we are not in the initial user namespace posix
+	 * acls must be translated.
+	 */
+	if (sb->s_user_ns != &init_user_ns)
+		sb->s_xattr = fuse_no_acl_xattr_handlers;
+
 	fc = kmalloc(sizeof(*fc), GFP_KERNEL);
 	err = -ENOMEM;
 	if (!fc)
fs/fuse/xattr.c +43 -0
index 3caac46b08b0..433717640f78 100644
@@ -192,6 +192,26 @@ static int fuse_xattr_set(const struct xattr_handler *handler,
 	return fuse_setxattr(inode, name, value, size, flags);
 }
 
+static bool no_xattr_list(struct dentry *dentry)
+{
+	return false;
+}
+
+static int no_xattr_get(const struct xattr_handler *handler,
+			struct dentry *dentry, struct inode *inode,
+			const char *name, void *value, size_t size)
+{
+	return -EOPNOTSUPP;
+}
+
+static int no_xattr_set(const struct xattr_handler *handler,
+			struct dentry *dentry, struct inode *nodee,
+			const char *name, const void *value,
+			size_t size, int flags)
+{
+	return -EOPNOTSUPP;
+}
+
 static const struct xattr_handler fuse_xattr_handler = {
 	.prefix = "",
 	.get    = fuse_xattr_get,
@@ -209,3 +229,26 @@ const struct xattr_handler *fuse_acl_xattr_handlers[] = {
 	&fuse_xattr_handler,
 	NULL
 };
+
+static const struct xattr_handler fuse_no_acl_access_xattr_handler = {
+	.name  = XATTR_NAME_POSIX_ACL_ACCESS,
+	.flags = ACL_TYPE_ACCESS,
+	.list  = no_xattr_list,
+	.get   = no_xattr_get,
+	.set   = no_xattr_set,
+};
+
+static const struct xattr_handler fuse_no_acl_default_xattr_handler = {
+	.name  = XATTR_NAME_POSIX_ACL_DEFAULT,
+	.flags = ACL_TYPE_ACCESS,
+	.list  = no_xattr_list,
+	.get   = no_xattr_get,
+	.set   = no_xattr_set,
+};
+
+const struct xattr_handler *fuse_no_acl_xattr_handlers[] = {
+	&fuse_no_acl_access_xattr_handler,
+	&fuse_no_acl_default_xattr_handler,
+	&fuse_xattr_handler,
+	NULL
+};
#8 lore raw
In reply to Eric W. Biederman
Quoted 11 lines · [email protected] (Eric W. Biederman) writes:
Quoted 9 lines · [email protected] (Eric W. Biederman) writes:

Ensure the translation happens by failing to read or write posix acls when the filesystem has not indicated it supports posix acls.

This ensures that modern cached posix acl support is available and used when dealing with posix acls. This is important because only that path has the code to convernt the uids and gids in posix acls into the user namespace of a fuse filesystem.

Quoted 6 lines
Quoted 2 lines

---

ping.

Miklos are you around where you can look at this?

Perhaps I got the wrong email address.

Ping?

Quoted 100 lines
Quoted 100 lines

Miklos after several attempts to handle this better last cycle. I figure we should go with the stupid version for now. I think I know how to do better but I don't want that to gate forward progress on fully unprivileged fuse mounts. Especially as this is the last known issue to deal with.

 fs/fuse/fuse_i.h |  1 +
 fs/fuse/inode.c  |  7 +++++++
 fs/fuse/xattr.c  | 43 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+)
fs/fuse/fuse_i.h +1 -0
index f630951df8dc..5256ad333b05 100644
@@ -985,6 +985,7 @@ ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size);
 int fuse_removexattr(struct inode *inode, const char *name);
 extern const struct xattr_handler *fuse_xattr_handlers[];
 extern const struct xattr_handler *fuse_acl_xattr_handlers[];
+extern const struct xattr_handler *fuse_no_acl_xattr_handlers[];
 
 struct posix_acl;
 struct posix_acl *fuse_get_acl(struct inode *inode, int type);
fs/fuse/inode.c +7 -0
index 1643043d4fe5..22c76cf8c2e3 100644
@@ -1100,6 +1100,13 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
 	    file->f_cred->user_ns != sb->s_user_ns)
 		goto err_fput;
 
+	/*
+	 * If we are not in the initial user namespace posix
+	 * acls must be translated.
+	 */
+	if (sb->s_user_ns != &init_user_ns)
+		sb->s_xattr = fuse_no_acl_xattr_handlers;
+
 	fc = kmalloc(sizeof(*fc), GFP_KERNEL);
 	err = -ENOMEM;
 	if (!fc)
fs/fuse/xattr.c +43 -0
index 3caac46b08b0..433717640f78 100644
@@ -192,6 +192,26 @@ static int fuse_xattr_set(const struct xattr_handler *handler,
 	return fuse_setxattr(inode, name, value, size, flags);
 }
 
+static bool no_xattr_list(struct dentry *dentry)
+{
+	return false;
+}
+
+static int no_xattr_get(const struct xattr_handler *handler,
+			struct dentry *dentry, struct inode *inode,
+			const char *name, void *value, size_t size)
+{
+	return -EOPNOTSUPP;
+}
+
+static int no_xattr_set(const struct xattr_handler *handler,
+			struct dentry *dentry, struct inode *nodee,
+			const char *name, const void *value,
+			size_t size, int flags)
+{
+	return -EOPNOTSUPP;
+}
+
 static const struct xattr_handler fuse_xattr_handler = {
 	.prefix = "",
 	.get    = fuse_xattr_get,
@@ -209,3 +229,26 @@ const struct xattr_handler *fuse_acl_xattr_handlers[] = {
 	&fuse_xattr_handler,
 	NULL
 };
+
+static const struct xattr_handler fuse_no_acl_access_xattr_handler = {
+	.name  = XATTR_NAME_POSIX_ACL_ACCESS,
+	.flags = ACL_TYPE_ACCESS,
+	.list  = no_xattr_list,
+	.get   = no_xattr_get,
+	.set   = no_xattr_set,
+};
+
+static const struct xattr_handler fuse_no_acl_default_xattr_handler = {
+	.name  = XATTR_NAME_POSIX_ACL_DEFAULT,
+	.flags = ACL_TYPE_ACCESS,
+	.list  = no_xattr_list,
+	.get   = no_xattr_get,
+	.set   = no_xattr_set,
+};
+
+const struct xattr_handler *fuse_no_acl_xattr_handlers[] = {
+	&fuse_no_acl_access_xattr_handler,
+	&fuse_no_acl_default_xattr_handler,
+	&fuse_xattr_handler,
+	NULL
+};

A message that is not in the archive (sent off-list or not yet received): 877enmskec.fsf-aS9lmoZGLiVWk0Htik3J/[email protected]

#10 lore raw
Quoted 13 lines · Eric W. Biederman
Quoted 11 lines · ebiederm-aS9lmoZGLiVWk0Htik3J/[email protected] (Eric W. Biederman) writes:
Quoted 9 lines · ebiederm-aS9lmoZGLiVWk0Htik3J/[email protected] (Eric W. Biederman) writes:

Ensure the translation happens by failing to read or write posix acls when the filesystem has not indicated it supports posix acls.

This ensures that modern cached posix acl support is available and used when dealing with posix acls. This is important because only that path has the code to convernt the uids and gids in posix acls into the user namespace of a fuse filesystem.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

---

ping.

Miklos are you around where you can look at this?

Perhaps I got the wrong email address.

No, sorry. I'll queue this up for 4.18.

Just wanted to finish off overlayfs stuff before getting into fuse.

Thanks,
Miklos

Quoted 101 lines
Quoted 101 lines
Quoted 101 lines

Miklos after several attempts to handle this better last cycle. I figure we should go with the stupid version for now. I think I know how to do better but I don't want that to gate forward progress on fully unprivileged fuse mounts. Especially as this is the last known issue to deal with.

 fs/fuse/fuse_i.h |  1 +
 fs/fuse/inode.c  |  7 +++++++
 fs/fuse/xattr.c  | 43 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+)
fs/fuse/fuse_i.h +1 -0
index f630951df8dc..5256ad333b05 100644
@@ -985,6 +985,7 @@ ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size);
 int fuse_removexattr(struct inode *inode, const char *name);
 extern const struct xattr_handler *fuse_xattr_handlers[];
 extern const struct xattr_handler *fuse_acl_xattr_handlers[];
+extern const struct xattr_handler *fuse_no_acl_xattr_handlers[];
 
 struct posix_acl;
 struct posix_acl *fuse_get_acl(struct inode *inode, int type);
fs/fuse/inode.c +7 -0
index 1643043d4fe5..22c76cf8c2e3 100644
@@ -1100,6 +1100,13 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
         file->f_cred->user_ns != sb->s_user_ns)
             goto err_fput;
 
+    /*
+     * If we are not in the initial user namespace posix
+     * acls must be translated.
+     */
+    if (sb->s_user_ns != &init_user_ns)
+            sb->s_xattr = fuse_no_acl_xattr_handlers;
+
     fc = kmalloc(sizeof(*fc), GFP_KERNEL);
     err = -ENOMEM;
     if (!fc)
fs/fuse/xattr.c +43 -0
index 3caac46b08b0..433717640f78 100644
@@ -192,6 +192,26 @@ static int fuse_xattr_set(const struct xattr_handler *handler,
     return fuse_setxattr(inode, name, value, size, flags);
 }
 
+static bool no_xattr_list(struct dentry *dentry)
+{
+    return false;
+}
+
+static int no_xattr_get(const struct xattr_handler *handler,
+                    struct dentry *dentry, struct inode *inode,
+                    const char *name, void *value, size_t size)
+{
+    return -EOPNOTSUPP;
+}
+
+static int no_xattr_set(const struct xattr_handler *handler,
+                    struct dentry *dentry, struct inode *nodee,
+                    const char *name, const void *value,
+                    size_t size, int flags)
+{
+    return -EOPNOTSUPP;
+}
+
 static const struct xattr_handler fuse_xattr_handler = {
     .prefix = "",
     .get    = fuse_xattr_get,
@@ -209,3 +229,26 @@ const struct xattr_handler *fuse_acl_xattr_handlers[] = {
     &fuse_xattr_handler,
     NULL
 };
+
+static const struct xattr_handler fuse_no_acl_access_xattr_handler = {
+    .name  = XATTR_NAME_POSIX_ACL_ACCESS,
+    .flags = ACL_TYPE_ACCESS,
+    .list  = no_xattr_list,
+    .get   = no_xattr_get,
+    .set   = no_xattr_set,
+};
+
+static const struct xattr_handler fuse_no_acl_default_xattr_handler = {
+    .name  = XATTR_NAME_POSIX_ACL_DEFAULT,
+    .flags = ACL_TYPE_ACCESS,
+    .list  = no_xattr_list,
+    .get   = no_xattr_get,
+    .set   = no_xattr_set,
+};
+
+const struct xattr_handler *fuse_no_acl_xattr_handlers[] = {
+    &fuse_no_acl_access_xattr_handler,
+    &fuse_no_acl_default_xattr_handler,
+    &fuse_xattr_handler,
+    NULL
+};
#11 lore raw
In reply to Eric W. Biederman
Quoted 13 lines · Eric W. Biederman
Quoted 11 lines · [email protected] (Eric W. Biederman) writes:
Quoted 9 lines · [email protected] (Eric W. Biederman) writes:

Ensure the translation happens by failing to read or write posix acls when the filesystem has not indicated it supports posix acls.

This ensures that modern cached posix acl support is available and used when dealing with posix acls. This is important because only that path has the code to convernt the uids and gids in posix acls into the user namespace of a fuse filesystem.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

---

ping.

Miklos are you around where you can look at this?

Perhaps I got the wrong email address.

No, sorry. I'll queue this up for 4.18.

Just wanted to finish off overlayfs stuff before getting into fuse.

Thanks,
Miklos

Quoted 101 lines
Quoted 101 lines
Quoted 101 lines

Miklos after several attempts to handle this better last cycle. I figure we should go with the stupid version for now. I think I know how to do better but I don't want that to gate forward progress on fully unprivileged fuse mounts. Especially as this is the last known issue to deal with.

 fs/fuse/fuse_i.h |  1 +
 fs/fuse/inode.c  |  7 +++++++
 fs/fuse/xattr.c  | 43 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+)
fs/fuse/fuse_i.h +1 -0
index f630951df8dc..5256ad333b05 100644
@@ -985,6 +985,7 @@ ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size);
 int fuse_removexattr(struct inode *inode, const char *name);
 extern const struct xattr_handler *fuse_xattr_handlers[];
 extern const struct xattr_handler *fuse_acl_xattr_handlers[];
+extern const struct xattr_handler *fuse_no_acl_xattr_handlers[];
 
 struct posix_acl;
 struct posix_acl *fuse_get_acl(struct inode *inode, int type);
fs/fuse/inode.c +7 -0
index 1643043d4fe5..22c76cf8c2e3 100644
@@ -1100,6 +1100,13 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
         file->f_cred->user_ns != sb->s_user_ns)
             goto err_fput;
 
+    /*
+     * If we are not in the initial user namespace posix
+     * acls must be translated.
+     */
+    if (sb->s_user_ns != &init_user_ns)
+            sb->s_xattr = fuse_no_acl_xattr_handlers;
+
     fc = kmalloc(sizeof(*fc), GFP_KERNEL);
     err = -ENOMEM;
     if (!fc)
fs/fuse/xattr.c +43 -0
index 3caac46b08b0..433717640f78 100644
@@ -192,6 +192,26 @@ static int fuse_xattr_set(const struct xattr_handler *handler,
     return fuse_setxattr(inode, name, value, size, flags);
 }
 
+static bool no_xattr_list(struct dentry *dentry)
+{
+    return false;
+}
+
+static int no_xattr_get(const struct xattr_handler *handler,
+                    struct dentry *dentry, struct inode *inode,
+                    const char *name, void *value, size_t size)
+{
+    return -EOPNOTSUPP;
+}
+
+static int no_xattr_set(const struct xattr_handler *handler,
+                    struct dentry *dentry, struct inode *nodee,
+                    const char *name, const void *value,
+                    size_t size, int flags)
+{
+    return -EOPNOTSUPP;
+}
+
 static const struct xattr_handler fuse_xattr_handler = {
     .prefix = "",
     .get    = fuse_xattr_get,
@@ -209,3 +229,26 @@ const struct xattr_handler *fuse_acl_xattr_handlers[] = {
     &fuse_xattr_handler,
     NULL
 };
+
+static const struct xattr_handler fuse_no_acl_access_xattr_handler = {
+    .name  = XATTR_NAME_POSIX_ACL_ACCESS,
+    .flags = ACL_TYPE_ACCESS,
+    .list  = no_xattr_list,
+    .get   = no_xattr_get,
+    .set   = no_xattr_set,
+};
+
+static const struct xattr_handler fuse_no_acl_default_xattr_handler = {
+    .name  = XATTR_NAME_POSIX_ACL_DEFAULT,
+    .flags = ACL_TYPE_ACCESS,
+    .list  = no_xattr_list,
+    .get   = no_xattr_get,
+    .set   = no_xattr_set,
+};
+
+const struct xattr_handler *fuse_no_acl_xattr_handlers[] = {
+    &fuse_no_acl_access_xattr_handler,
+    &fuse_no_acl_default_xattr_handler,
+    &fuse_xattr_handler,
+    NULL
+};

A message that is not in the archive (sent off-list or not yet received): CAOssrKdS9gOsZrNfqJbk_j0Z8-hrqrYWW+=_Z5mUEX1KE-Kw6Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#13 lore raw
Quoted 20 lines · Miklos Szeredi
Quoted 18 lines · Eric W. Biederman
Quoted 16 lines · ebiederm-aS9lmoZGLiVWk0Htik3J/[email protected] (Eric W. Biederman) writes:
Quoted 11 lines · ebiederm-aS9lmoZGLiVWk0Htik3J/[email protected] (Eric W. Biederman) writes:

Ensure the translation happens by failing to read or write posix acls when the filesystem has not indicated it supports posix acls.

This ensures that modern cached posix acl support is available and used when dealing with posix acls. This is important because only that path has the code to convernt the uids and gids in posix acls into the user namespace of a fuse filesystem.

---

ping.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Miklos are you around where you can look at this?

Perhaps I got the wrong email address.

No, sorry. I'll queue this up for 4.18.

Just wanted to finish off overlayfs stuff before getting into fuse.

After reading your overlayfs pull it looks like those were some tricky issues you were dealing with so it makes complete sense.

Then I am going to send you the enablement patch as I think the initial round of work is done and you can apply them when you are ready.

Eric

#14 lore raw
In reply to Miklos Szeredi
Quoted 20 lines · Miklos Szeredi
Quoted 18 lines · Eric W. Biederman
Quoted 16 lines · [email protected] (Eric W. Biederman) writes:
Quoted 11 lines · [email protected] (Eric W. Biederman) writes:

Ensure the translation happens by failing to read or write posix acls when the filesystem has not indicated it supports posix acls.

This ensures that modern cached posix acl support is available and used when dealing with posix acls. This is important because only that path has the code to convernt the uids and gids in posix acls into the user namespace of a fuse filesystem.

---

ping.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Miklos are you around where you can look at this?

Perhaps I got the wrong email address.

No, sorry. I'll queue this up for 4.18.

Just wanted to finish off overlayfs stuff before getting into fuse.

After reading your overlayfs pull it looks like those were some tricky issues you were dealing with so it makes complete sense.

Then I am going to send you the enablement patch as I think the initial round of work is done and you can apply them when you are ready.

Eric

#15 lore raw

PATCH 1/1 fuse: Allow fully unprivileged mounts

Now that the fuse and the vfs work is complete. Allow the fuse filesystem to be mounted by the root user in a user namespace.

---
 fs/fuse/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fuse/inode.c +1 -1
index 22c76cf8c2e3..48baa26993f3 100644
@@ -1222,7 +1222,7 @@ static void fuse_kill_sb_anon(struct super_block *sb)
 static struct file_system_type fuse_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "fuse",
-	.fs_flags	= FS_HAS_SUBTYPE,
+	.fs_flags	= FS_HAS_SUBTYPE | FS_USERNS_MOUNT,
 	.mount		= fuse_mount,
 	.kill_sb	= fuse_kill_sb_anon,
 };
Signature · 1 line
2.14.1

A message that is not in the archive (sent off-list or not yet received): 87tvqqo8w1.fsf_-_-aS9lmoZGLiVWk0Htik3J/[email protected]

#17 lore raw

Re: [PATCH] fuse: Allow fully unprivileged mounts

Quoted 3 lines · Eric W. Biederman

Now that the fuse and the vfs work is complete. Allow the fuse filesystem to be mounted by the root user in a user namespace.

Thanks, pushed to for-next branch of the fuse tree toghether with the xattr fix.

Miklos

maintainer
#18 lore raw

Re: [PATCH] fuse: Allow fully unprivileged mounts

In reply to Eric W. Biederman
Quoted 3 lines · Eric W. Biederman

Now that the fuse and the vfs work is complete. Allow the fuse filesystem to be mounted by the root user in a user namespace.

Thanks, pushed to for-next branch of the fuse tree toghether with the xattr fix.

Miklos