On 8/31/23 15:40, Christian Brauner wrote:
On Thu, Aug 31, 2023 at 01:24:30PM +0200, Bernd Schubert wrote:
File systems want to hold a shared lock for DIO writes,
but may need to drop file priveliges - that a requires an
exclusive lock. The new export function file_needs_remove_privs()
is added in order to first check if that is needed.
Cc: Miklos Szeredi <miklos@xxxxxxxxxx>
Cc: Dharmendra Singh <dsingh@xxxxxxx>
Cc: Josef Bacik <josef@xxxxxxxxxxxxxx>
Cc: linux-btrfs@xxxxxxxxxxxxxxx
Cc: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx>
Cc: Christian Brauner <brauner@xxxxxxxxxx>
Cc: linux-fsdevel@xxxxxxxxxxxxxxx
Signed-off-by: Bernd Schubert <bschubert@xxxxxxx>
---
fs/inode.c | 8 ++++++++
include/linux/fs.h | 1 +
2 files changed, 9 insertions(+)
diff --git a/fs/inode.c b/fs/inode.c
index 67611a360031..9b05db602e41 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2013,6 +2013,14 @@ int dentry_needs_remove_privs(struct mnt_idmap *idmap,
return mask;
}
+int file_needs_remove_privs(struct file *file)
+{
+ struct dentry *dentry = file_dentry(file);
+
+ return dentry_needs_remove_privs(file_mnt_idmap(file), dentry);
Ugh, I wanted to propose to get rid of this dentry dance but I propsed
that before and remembered it's because of __vfs_getxattr() which is
called from the capability security hook that we need it...
Is there anything specific you are suggesting?
And thanks for typo/grammar annotations, I'm going to wait for btrfs
feedback before I'm going to send a new version.
Thanks,
Bernd