mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
open: handle idmapped mounts in do_truncate()
When truncating files the vfs will verify that the caller is privileged over the inode. Extend it to handle idmapped mounts. If the inode is accessed through an idmapped mount it is mapped according to the mount's user namespace. Afterwards the permissions checks are identical to non-idmapped mounts. If the initial user namespace is passed nothing changes so non-idmapped mounts will see identical behavior as before. Link: https://lore.kernel.org/r/20210121131959.646623-16-christian.brauner@ubuntu.com Cc: Christoph Hellwig <hch@lst.de> Cc: David Howells <dhowells@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: linux-fsdevel@vger.kernel.org Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
@@ -1903,7 +1903,8 @@ int dentry_needs_remove_privs(struct dentry *dentry)
|
||||
return mask;
|
||||
}
|
||||
|
||||
static int __remove_privs(struct dentry *dentry, int kill)
|
||||
static int __remove_privs(struct user_namespace *mnt_userns,
|
||||
struct dentry *dentry, int kill)
|
||||
{
|
||||
struct iattr newattrs;
|
||||
|
||||
@@ -1912,7 +1913,7 @@ static int __remove_privs(struct dentry *dentry, int kill)
|
||||
* Note we call this on write, so notify_change will not
|
||||
* encounter any conflicting delegations:
|
||||
*/
|
||||
return notify_change(&init_user_ns, dentry, &newattrs, NULL);
|
||||
return notify_change(mnt_userns, dentry, &newattrs, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1939,7 +1940,7 @@ int file_remove_privs(struct file *file)
|
||||
if (kill < 0)
|
||||
return kill;
|
||||
if (kill)
|
||||
error = __remove_privs(dentry, kill);
|
||||
error = __remove_privs(file_mnt_user_ns(file), dentry, kill);
|
||||
if (!error)
|
||||
inode_has_no_xattr(inode);
|
||||
|
||||
|
Reference in New Issue
Block a user