path: root/fs/fat/file.c
diff options
authorChristian Brauner <>2022-06-21 16:14:53 +0200
committerChristian Brauner (Microsoft) <>2022-06-26 18:18:56 +0200
commit0e363cf3fa598c69340794da068d4d9cbc869322 (patch)
treea1b1b648f6cb3f9b09a41c44b0f3c8c2a3e17422 /fs/fat/file.c
parent71e7b535b8900d7ce7d5279fa472711db5251ae5 (diff)
security: pass down mount idmapping to setattr hook
Before this change we used to take a shortcut and place the actual values that would be written to inode->i_{g,u}id into struct iattr. This had the advantage that we moved idmappings mostly out of the picture early on but it made reasoning about changes more difficult than it should be. The filesystem was never explicitly told that it dealt with an idmapped mount. The transition to the value that needed to be stored in inode->i_{g,u}id appeared way too early and increased the probability of bugs in various codepaths. We know place the same value in struct iattr no matter if this is an idmapped mount or not. The vfs will only deal with type safe vfs{g,u}id_t. This makes it massively safer to perform permission checks as the type will tell us what checks we need to perform and what helpers we need to use. Adapt the security_inode_setattr() helper to pass down the mount's idmapping to account for that change. Link: Cc: Seth Forshee <> Cc: Christoph Hellwig <> Cc: Aleksa Sarai <> Cc: Linus Torvalds <> Cc: Al Viro <> CC: Reviewed-by: Seth Forshee <> Signed-off-by: Christian Brauner (Microsoft) <>
Diffstat (limited to 'fs/fat/file.c')
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/fat/file.c b/fs/fat/file.c
index 3dae3ed60f3a..530f18173db2 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -90,7 +90,8 @@ static int fat_ioctl_set_attributes(struct file *file, u32 __user *user_attr)
* out the RO attribute for checking by the security
* module, just because it maps to a file mode.
- err = security_inode_setattr(file->f_path.dentry, &ia);
+ err = security_inode_setattr(&init_user_ns,
+ file->f_path.dentry, &ia);
if (err)
goto out_unlock_inode;