Whamcloud - gitweb
LU-18101 sec: fix ACL handling on recent kernels again 52/56552/4 master
authorSebastien Buisson <sbuisson@ddn.com>
Tue, 1 Oct 2024 16:20:25 +0000 (18:20 +0200)
committerOleg Drokin <green@whamcloud.com>
Fri, 4 Oct 2024 00:17:29 +0000 (00:17 +0000)
On recent distributions like Ubuntu 24.04, the kernel offers the
.get_inode_acl op on struct inode_operations. This must be defined
and fetch ACLs, otherwise they can end up being incorrect on inodes.

Fixes: aa636f8ae6 ("LU-18095 sec: fix ACL handling on recent kernels")
Test-Parameters: testlist=sanityn env=ONLY=25a,ONLY_REPEAT=10 mdscount=2 mdtcount=4 osscount=1 ostcount=8 clientcount=2
Test-Parameters: testlist=sanityn env=ONLY=25a,ONLY_REPEAT=10 mdscount=2 mdtcount=4 osscount=1 ostcount=8 clientcount=2 clientdistro=ubuntu2404 serverdistro=el8.8
Test-Parameters: testlist=sanity-sec env=ONLY=23b,ONLY_REPEAT=50 mdscount=2 mdtcount=4 osscount=1 ostcount=8 clientcount=2 clientdistro=ubuntu2404 serverdistro=el8.8
Test-Parameters: testlist=sanity env=ONLY=103a,ONLY_REPEAT=50 mdscount=2 mdtcount=4 osscount=1 ostcount=8 clientcount=2 clientdistro=ubuntu2404 serverdistro=el8.8
Signed-off-by: Sebastien Buisson <sbuisson@ddn.com>
Change-Id: Idcc642a11f6f6198217e5eadb2a2c32e8117b8b7
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56552
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/autoconf/lustre-core.m4
lustre/llite/acl.c
lustre/llite/file.c
lustre/llite/llite_internal.h
lustre/llite/namei.c

index 46286a0..c81541e 100644 (file)
@@ -4140,6 +4140,28 @@ AC_DEFUN([LC_HAVE_ACL_WITH_DENTRY], [
 ]) # LC_HAVE_ACL_WITH_DENTRY
 
 #
+# LC_IOP_GET_INODE_ACL
+#
+# linux kernel v6.1-rc1-3-gcac2f8b8d8
+#   fs: rename current get acl method
+#
+AC_DEFUN([LC_SRC_IOP_GET_INODE_ACL], [
+       LB2_LINUX_TEST_SRC([inode_ops_get_inode_acl], [
+               #include <linux/fs.h>
+       ],[
+               struct inode_operations iop;
+               iop.get_inode_acl = NULL;
+       ])
+])
+AC_DEFUN([LC_IOP_GET_INODE_ACL], [
+       LB2_MSG_LINUX_TEST_RESULT([if inode_operations has .get_inode_acl member function],
+       [inode_ops_get_inode_acl], [
+               AC_DEFINE(HAVE_IOP_GET_INODE_ACL, 1,
+                       [inode_operations has .get_inode_acl member function])
+       ])
+]) # LC_IOP_GET_INODE_ACL
+
+#
 # LC_HAVE_U64_CAPABILITY
 #
 # linux kernel v6.2-13111-gf122a08b197d
@@ -4923,6 +4945,7 @@ AC_DEFUN([LC_PROG_LINUX_SRC], [
        LC_SRC_HAVE_GET_RANDOM_U32_AND_U64
        LC_SRC_NFS_FILLDIR_USE_CTX_RETURN_BOOL
        LC_SRC_HAVE_FILEMAP_GET_FOLIOS_CONTIG
+       LC_SRC_IOP_GET_INODE_ACL
 
        # 6.2
        LC_SRC_HAVE_GET_RANDOM_U32_BELOW
@@ -5238,6 +5261,7 @@ AC_DEFUN([LC_PROG_LINUX_RESULTS], [
        LC_HAVE_GET_RANDOM_U32_AND_U64
        LC_NFS_FILLDIR_USE_CTX_RETURN_BOOL
        LC_HAVE_FILEMAP_GET_FOLIOS_CONTIG
+       LC_IOP_GET_INODE_ACL
 
        # 6.2
        LC_HAVE_GET_RANDOM_U32_BELOW
index 2afd352..9fa960d 100644 (file)
 
 #include "llite_internal.h"
 
-struct posix_acl *ll_get_acl(
- #ifdef HAVE_ACL_WITH_DENTRY
-       struct mnt_idmap *map, struct dentry *dentry, int type)
- #elif defined HAVE_GET_ACL_RCU_ARG
-       struct inode *inode, int type, bool rcu)
- #else
-       struct inode *inode, int type)
- #endif /* HAVE_GET_ACL_RCU_ARG */
+struct posix_acl *
+ll_get_inode_acl(struct inode *inode, int type, bool rcu)
 {
-#ifdef HAVE_ACL_WITH_DENTRY
-       struct inode *inode = dentry->d_inode;
-#endif
        struct ll_inode_info *lli = ll_i2info(inode);
        struct posix_acl *acl = NULL;
        char *value = NULL;
@@ -58,10 +49,8 @@ struct posix_acl *ll_get_acl(
        char *xname;
        ENTRY;
 
-#ifdef HAVE_GET_ACL_RCU_ARG
        if (rcu)
                return ERR_PTR(-ECHILD);
-#endif
 
        if (type == ACL_TYPE_ACCESS && lli->lli_posix_acl)
                goto lli_acl;
@@ -118,6 +107,25 @@ out:
        RETURN(acl);
 }
 
+struct posix_acl *ll_get_acl(
+#ifdef HAVE_ACL_WITH_DENTRY
+       struct mnt_idmap *map, struct dentry *dentry, int type)
+#elif defined HAVE_GET_ACL_RCU_ARG
+       struct inode *inode, int type, bool rcu)
+#else
+       struct inode *inode, int type)
+#endif /* HAVE_GET_ACL_RCU_ARG */
+{
+#ifdef HAVE_ACL_WITH_DENTRY
+       struct inode *inode = dentry->d_inode;
+#endif
+#ifndef HAVE_GET_ACL_RCU_ARG
+       bool rcu = false;
+#endif
+
+       return ll_get_inode_acl(inode, type, rcu);
+}
+
 #ifdef HAVE_IOP_SET_ACL
 int ll_set_acl(struct mnt_idmap *map,
 #ifdef HAVE_ACL_WITH_DENTRY
index 49d938a..4d364de 100644 (file)
@@ -6376,6 +6376,9 @@ const struct inode_operations ll_file_inode_operations = {
 #endif
        .listxattr      = ll_listxattr,
        .fiemap         = ll_fiemap,
+#ifdef HAVE_IOP_GET_INODE_ACL
+       .get_inode_acl  = ll_get_inode_acl,
+#endif
        .get_acl        = ll_get_acl,
 #ifdef HAVE_IOP_SET_ACL
        .set_acl        = ll_set_acl,
index bafc418..c57d486 100644 (file)
@@ -1394,6 +1394,9 @@ struct posix_acl *ll_get_acl(
        struct inode *inode, int type);
 #endif /* HAVE_GET_ACL_RCU_ARG */
 
+struct posix_acl *
+ll_get_inode_acl(struct inode *inode, int type, bool rcu);
+
 int ll_set_acl(struct mnt_idmap *mnt_userns,
 #ifdef HAVE_ACL_WITH_DENTRY
               struct dentry *dentry,
index 653b8b2..a74f882 100644 (file)
@@ -2441,6 +2441,9 @@ const struct inode_operations ll_dir_inode_operations = {
        .removexattr    = ll_removexattr,
 #endif
        .listxattr      = ll_listxattr,
+#ifdef HAVE_IOP_GET_INODE_ACL
+       .get_inode_acl  = ll_get_inode_acl,
+#endif
        .get_acl        = ll_get_acl,
 #ifdef HAVE_IOP_SET_ACL
        .set_acl        = ll_set_acl,
@@ -2461,6 +2464,9 @@ const struct inode_operations ll_special_inode_operations = {
        .removexattr    = ll_removexattr,
 #endif
        .listxattr      = ll_listxattr,
+#ifdef HAVE_IOP_GET_INODE_ACL
+       .get_inode_acl  = ll_get_inode_acl,
+#endif
        .get_acl        = ll_get_acl,
 #ifdef HAVE_IOP_SET_ACL
        .set_acl        = ll_set_acl,