Merge tag 'thermal-6.2-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
[linux-block.git] / fs / ecryptfs / inode.c
index c214fe0981bdc333f1fdd75a47ef7454d971d2c7..f3cd00fac9c3aa3f9a717c2cddaec693293d0642 100644 (file)
@@ -18,6 +18,8 @@
 #include <linux/fs_stack.h>
 #include <linux/slab.h>
 #include <linux/xattr.h>
+#include <linux/posix_acl.h>
+#include <linux/posix_acl_xattr.h>
 #include <linux/fileattr.h>
 #include <asm/unaligned.h>
 #include "ecryptfs_kernel.h"
@@ -1120,6 +1122,28 @@ static int ecryptfs_fileattr_set(struct user_namespace *mnt_userns,
        return rc;
 }
 
+static struct posix_acl *ecryptfs_get_acl(struct user_namespace *mnt_userns,
+                                         struct dentry *dentry, int type)
+{
+       return vfs_get_acl(mnt_userns, ecryptfs_dentry_to_lower(dentry),
+                          posix_acl_xattr_name(type));
+}
+
+static int ecryptfs_set_acl(struct user_namespace *mnt_userns,
+                           struct dentry *dentry, struct posix_acl *acl,
+                           int type)
+{
+       int rc;
+       struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
+       struct inode *lower_inode = d_inode(lower_dentry);
+
+       rc = vfs_set_acl(&init_user_ns, lower_dentry,
+                        posix_acl_xattr_name(type), acl);
+       if (!rc)
+               fsstack_copy_attr_all(d_inode(dentry), lower_inode);
+       return rc;
+}
+
 const struct inode_operations ecryptfs_symlink_iops = {
        .get_link = ecryptfs_get_link,
        .permission = ecryptfs_permission,
@@ -1143,6 +1167,8 @@ const struct inode_operations ecryptfs_dir_iops = {
        .listxattr = ecryptfs_listxattr,
        .fileattr_get = ecryptfs_fileattr_get,
        .fileattr_set = ecryptfs_fileattr_set,
+       .get_acl = ecryptfs_get_acl,
+       .set_acl = ecryptfs_set_acl,
 };
 
 const struct inode_operations ecryptfs_main_iops = {
@@ -1152,6 +1178,8 @@ const struct inode_operations ecryptfs_main_iops = {
        .listxattr = ecryptfs_listxattr,
        .fileattr_get = ecryptfs_fileattr_get,
        .fileattr_set = ecryptfs_fileattr_set,
+       .get_acl = ecryptfs_get_acl,
+       .set_acl = ecryptfs_set_acl,
 };
 
 static int ecryptfs_xattr_get(const struct xattr_handler *handler,
@@ -1182,6 +1210,10 @@ static const struct xattr_handler ecryptfs_xattr_handler = {
 };
 
 const struct xattr_handler *ecryptfs_xattr_handlers[] = {
+#ifdef CONFIG_FS_POSIX_ACL
+       &posix_acl_access_xattr_handler,
+       &posix_acl_default_xattr_handler,
+#endif
        &ecryptfs_xattr_handler,
        NULL
 };