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

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