Blame SOURCES/0067-attr-handle-idmapped-mounts.patch

Kmods SIG 50e2b3
From 2f221d6f7b881d95de1f356a3097d755ab1e47d4 Mon Sep 17 00:00:00 2001
Kmods SIG 50e2b3
From: Christian Brauner <christian.brauner@ubuntu.com>
Kmods SIG 50e2b3
Date: Thu, 21 Jan 2021 14:19:26 +0100
Kmods SIG 50e2b3
Subject: [Backport 2f221d6f7b88] attr: handle idmapped mounts
Kmods SIG 50e2b3
Kmods SIG 50e2b3
When file attributes are changed most filesystems rely on the
Kmods SIG 50e2b3
setattr_prepare(), setattr_copy(), and notify_change() helpers for
Kmods SIG 50e2b3
initialization and permission checking. Let them handle idmapped mounts.
Kmods SIG 50e2b3
If the inode is accessed through an idmapped mount map it into the
Kmods SIG 50e2b3
mount's user namespace. Afterwards the checks are identical to
Kmods SIG 50e2b3
non-idmapped mounts. If the initial user namespace is passed nothing
Kmods SIG 50e2b3
changes so non-idmapped mounts will see identical behavior as before.
Kmods SIG 50e2b3
Kmods SIG 50e2b3
Helpers that perform checks on the ia_uid and ia_gid fields in struct
Kmods SIG 50e2b3
iattr assume that ia_uid and ia_gid are intended values and have already
Kmods SIG 50e2b3
been mapped correctly at the userspace-kernelspace boundary as we
Kmods SIG 50e2b3
already do today. If the initial user namespace is passed nothing
Kmods SIG 50e2b3
changes so non-idmapped mounts will see identical behavior as before.
Kmods SIG 50e2b3
Kmods SIG 50e2b3
Link: https://lore.kernel.org/r/20210121131959.646623-8-christian.brauner@ubuntu.com
Kmods SIG 50e2b3
Cc: Christoph Hellwig <hch@lst.de>
Kmods SIG 50e2b3
Cc: David Howells <dhowells@redhat.com>
Kmods SIG 50e2b3
Cc: Al Viro <viro@zeniv.linux.org.uk>
Kmods SIG 50e2b3
Cc: linux-fsdevel@vger.kernel.org
Kmods SIG 50e2b3
Reviewed-by: Christoph Hellwig <hch@lst.de>
Kmods SIG 50e2b3
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Kmods SIG 50e2b3
---
Kmods SIG 50e2b3
 src/file.c | 4 ++--
Kmods SIG 50e2b3
 1 file changed, 2 insertions(+), 2 deletions(-)
Kmods SIG 50e2b3
Kmods SIG 50e2b3
diff --git a/src/file.c b/src/file.c
Kmods SIG 50e2b3
index a92478eabfa4e43f2198ccf9b62b8632b697c8dc..ace35aa8e64b7f416f26cfa194253d27389dfc7f 100644
Kmods SIG 50e2b3
--- a/src/file.c
Kmods SIG 50e2b3
+++ b/src/file.c
Kmods SIG 50e2b3
@@ -305,7 +305,7 @@ int exfat_setattr(struct dentry *dentry, struct iattr *attr)
Kmods SIG 50e2b3
 				ATTR_TIMES_SET);
Kmods SIG 50e2b3
 	}
Kmods SIG 50e2b3
 
Kmods SIG 50e2b3
-	error = setattr_prepare(dentry, attr);
Kmods SIG 50e2b3
+	error = setattr_prepare(&init_user_ns, dentry, attr);
Kmods SIG 50e2b3
 	attr->ia_valid = ia_valid;
Kmods SIG 50e2b3
 	if (error)
Kmods SIG 50e2b3
 		goto out;
Kmods SIG 50e2b3
@@ -340,7 +340,7 @@ int exfat_setattr(struct dentry *dentry, struct iattr *attr)
Kmods SIG 50e2b3
 		up_write(&EXFAT_I(inode)->truncate_lock);
Kmods SIG 50e2b3
 	}
Kmods SIG 50e2b3
 
Kmods SIG 50e2b3
-	setattr_copy(inode, attr);
Kmods SIG 50e2b3
+	setattr_copy(&init_user_ns, inode, attr);
Kmods SIG 50e2b3
 	exfat_truncate_atime(&inode->i_atime);
Kmods SIG 50e2b3
 	mark_inode_dirty(inode);
Kmods SIG 50e2b3
 
Kmods SIG 50e2b3
-- 
Kmods SIG 50e2b3
2.31.1
Kmods SIG 50e2b3