From 13fd5ebef3a7a1ae3574458674e16ca782b181e7 Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Tue, 1 Oct 2024 18:20:25 +0200 Subject: [PATCH] LU-18101 sec: fix ACL handling on recent kernels again 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 Change-Id: Idcc642a11f6f6198217e5eadb2a2c32e8117b8b7 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56552 Reviewed-by: Jian Yu Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo --- lustre/autoconf/lustre-core.m4 | 24 ++++++++++++++++++++++++ lustre/llite/acl.c | 34 +++++++++++++++++++++------------- lustre/llite/file.c | 3 +++ lustre/llite/llite_internal.h | 3 +++ lustre/llite/namei.c | 6 ++++++ 5 files changed, 57 insertions(+), 13 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 46286a0..c81541e 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -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 + ],[ + 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 diff --git a/lustre/llite/acl.c b/lustre/llite/acl.c index 2afd352..9fa960d 100644 --- a/lustre/llite/acl.c +++ b/lustre/llite/acl.c @@ -38,18 +38,9 @@ #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 diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 49d938a..4d364de 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -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, diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index bafc418..c57d486 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -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, diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index 653b8b2..a74f882 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -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, -- 1.8.3.1