From 76fc6f9f571d59654e9e9501bd6ba4e4fa995ea8 Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Thu, 27 Mar 2025 08:42:38 +0700 Subject: [PATCH] LU-18852 build: Compatability updates for kernel v6.14 Linux commit v6.13-rc1-1-g6fba89813ccf lsm: ensure the correct LSM context releaser struct lsm_context is now upstream, provide an lsmcontext mapping for Ubuntu Linux v6.13-rc1-7-g5be1fa8abd7b Pass parent directory inode and expected name to ->d_revalidate() Adjust d_revalidate() to handle the extra arguments. Use FMODE_NONOTIFY now that __FMODE_NONOTIFY macro is dropped. Test-Parameters: trivial HPE-bug-id: LUS-12797 Signed-off-by: Shaun Tancheff Change-Id: I4ea10d171ab83e6cadb7d03580e9a2748c0d60b0 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58551 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Jian Yu Reviewed-by: Yang Sheng Reviewed-by: Oleg Drokin --- config/lustre-build.m4 | 2 ++ config/lustre-core.m4 | 78 ++++++++++++++++++++++++++++++++++------ libcfs/libcfs/crypto/crypto.c | 6 +++- lustre/include/lustre_compat.h | 4 +-- lustre/include/lvfs.h | 4 ++- lustre/llite/dcache.c | 6 +++- lustre/llite/xattr_security.c | 2 +- lustre/osd-ldiskfs/osd_handler.c | 2 +- 8 files changed, 87 insertions(+), 17 deletions(-) diff --git a/config/lustre-build.m4 b/config/lustre-build.m4 index bf31cb5..f5e4366 100644 --- a/config/lustre-build.m4 +++ b/config/lustre-build.m4 @@ -188,6 +188,7 @@ AC_DEFUN([LB_KABI_CHECKS], [ LIBCFS_SRC_HAVE_WAIT_BIT_HEADER LIBCFS_SRC_LINUX_BLK_INTEGRITY_HEADER LIBCFS_SRC_HAVE_MMAP_LOCK + LC_SRC_STRUCT_LSM_CONTEXT_EARLY LB2_LINUX_TEST_COMPILE_ALL([early], [for available lustre kapi interfaces]) @@ -196,6 +197,7 @@ AC_DEFUN([LB_KABI_CHECKS], [ LIBCFS_HAVE_WAIT_BIT_HEADER LIBCFS_LINUX_BLK_INTEGRITY_HEADER LIBCFS_HAVE_MMAP_LOCK + LC_STRUCT_LSM_CONTEXT_EARLY # Run any parallel compile tests LB_PROG_LINUX_SRC diff --git a/config/lustre-core.m4 b/config/lustre-core.m4 index f639aad..2cdb1bc 100644 --- a/config/lustre-core.m4 +++ b/config/lustre-core.m4 @@ -3813,7 +3813,7 @@ AC_DEFUN([LC_SRC_HAVE_LSMCONTEXT_INIT], [ LB2_LINUX_TEST_SRC([lsmcontext_init], [ #include ],[ - struct lsmcontext ctx = {}; + struct lsm_context ctx = {}; lsmcontext_init(&ctx, "", 0, 0); ],[]) @@ -3831,7 +3831,7 @@ AC_DEFUN([LC_HAVE_LSMCONTEXT_INIT], [ # # repo: git://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/jammy # kernel linux-hwe-5.19 commit 57d0004bc811254916be30f94c86d9607867deb0 -# LSM: Use lsmcontext in security_dentry_init_security +# LSM: Use lsm_context in security_dentry_init_security # AC_DEFUN([LC_SRC_SECURITY_DENTRY_INIT_SECURTY_WITH_CTX], [ LB2_LINUX_TEST_SRC([security_dentry_init_security_with_ctx], [ @@ -3839,7 +3839,7 @@ AC_DEFUN([LC_SRC_SECURITY_DENTRY_INIT_SECURTY_WITH_CTX], [ ],[ struct dentry *dentry = NULL; const struct qstr *name = NULL; - struct lsmcontext *ctx = NULL; + struct lsm_context *ctx = NULL; const char *xattr_name = ""; (void)security_dentry_init_security(dentry, 0, name, @@ -3847,10 +3847,10 @@ AC_DEFUN([LC_SRC_SECURITY_DENTRY_INIT_SECURTY_WITH_CTX], [ ],[-Werror]) ]) AC_DEFUN([LC_SECURITY_DENTRY_INIT_SECURTY_WITH_CTX], [ - LB2_MSG_LINUX_TEST_RESULT([if security_dentry_init_security needs lsmcontext], + LB2_MSG_LINUX_TEST_RESULT([if security_dentry_init_security needs lsm_context], [security_dentry_init_security_with_ctx], [ AC_DEFINE(HAVE_SECURITY_DENTRY_INIT_SECURTY_WITH_CTX, 1, - [security_dentry_init_security needs lsmcontext]) + [security_dentry_init_security needs lsm_context]) ]) ]) # LC_SECURITY_DENTRY_INIT_SECURTY_WITH_CTX @@ -3862,17 +3862,17 @@ AC_DEFUN([LC_SECURITY_DENTRY_INIT_SECURTY_WITH_CTX], [ # LSM stacking v39: LSM: Ensure the correct LSM context releaser # AC_DEFUN([LC_SRC_LSMCONTEXT_HAS_ID], [ - LB2_LINUX_TEST_SRC([lsmcontext_has_id], [ + LB2_LINUX_TEST_SRC([lsm_context_has_id], [ #include ],[ - ((struct lsmcontext *)1)->id = 0; + ((struct lsm_context *)1)->id = 0; ],[-Werror]) ]) AC_DEFUN([LC_LSMCONTEXT_HAS_ID], [ - LB2_MSG_LINUX_TEST_RESULT([if lsmcontext has id], - [lsmcontext_has_id], [ + LB2_MSG_LINUX_TEST_RESULT([if lsm_context has id], + [lsm_context_has_id], [ AC_DEFINE(HAVE_LSMCONTEXT_HAS_ID, 1, - [lsmcontext has id]) + [lsm_context has id]) ]) ]) # LC_LSMCONTEXT_HAS_ID @@ -5077,6 +5077,58 @@ AC_DEFUN([LC_HAVE_PAGEPRIVATE2], [ ]) # LC_HAVE_PAGEPRIVATE2 # +# LC_STRUCT_LSM_CONTEXT +# +# Linux commit v6.13-rc1-1-g6fba89813ccf +# lsm: ensure the correct LSM context releaser +# +AC_DEFUN([LC_SRC_STRUCT_LSM_CONTEXT_EARLY], [ + LB2_LINUX_TEST_SRC([struct_lsm_context], [ + #include + ],[ + struct lsm_context ctx = {}; + + ctx.context = NULL; + ],[-Werror]) +]) +AC_DEFUN([LC_STRUCT_LSM_CONTEXT_EARLY], [ + LB2_MSG_LINUX_TEST_RESULT([if struct lsm_context is available], + [struct_lsm_context], [ + AC_DEFINE(HAVE_STRUCT_LSM_CONTEXT, 1, + [struct lsm_context is available]) + ],[ + AC_DEFINE(lsm_context, lsmcontext, + [struct lsm_context also known as struct lsmcontext in ubuntu kernels]) + ]) +]) # LC_STRUCT_LSM_CONTEXT_EARLY + +# +# LC_HAVE_D_REVALIDATE_WITH_INODE_NAME +# +# Linux v6.13-rc1-7-g5be1fa8abd7b +# Pass parent directory inode and expected name to ->d_revalidate() +# +AC_DEFUN([LC_SRC_HAVE_D_REVALIDATE_WITH_INODE_NAME], [ + LB2_LINUX_TEST_SRC([dentry_ops_d_revalidate_inode_name], [ + #include + ],[ + struct dentry_operations *d_ops = NULL; + struct inode *inode = NULL; + struct qstr *qstr = NULL; + struct dentry *dentry = NULL; + + (void)d_ops->d_revalidate(inode, qstr, dentry, 0); + ],[-Werror]) +]) +AC_DEFUN([LC_HAVE_D_REVALIDATE_WITH_INODE_NAME], [ + LB2_MSG_LINUX_TEST_RESULT([if PagePrivate2() is available], + [dentry_ops_d_revalidate_inode_name], [ + AC_DEFINE(HAVE_D_REVALIDATE_WITH_INODE_NAME, 1, + [dentry operations d_revalidate() takes inode, name]) + ]) +]) # LC_HAVE_D_REVALIDATE_WITH_INODE_NAME + +# # LC_PROG_LINUX # # Lustre linux kernel checks @@ -5391,6 +5443,9 @@ AC_DEFUN([LC_PROG_LINUX_SRC], [ LC_SRC_HAVE_MODULE_IMPORT_STRING_LITERAL LC_SRC_HAVE_PAGEPRIVATE2 + # 6.14 + LC_SRC_HAVE_D_REVALIDATE_WITH_INODE_NAME + # kernel patch to extend integrity interface LC_SRC_BIO_INTEGRITY_PREP_FN ]) @@ -5727,6 +5782,9 @@ AC_DEFUN([LC_PROG_LINUX_RESULTS], [ LC_HAVE_MODULE_IMPORT_STRING_LITERAL LC_HAVE_PAGEPRIVATE2 + # 6.14 + LC_HAVE_D_REVALIDATE_WITH_INODE_NAME + # kernel patch to extend integrity interface LC_BIO_INTEGRITY_PREP_FN ]) diff --git a/libcfs/libcfs/crypto/crypto.c b/libcfs/libcfs/crypto/crypto.c index e06a160..4b5da91 100644 --- a/libcfs/libcfs/crypto/crypto.c +++ b/libcfs/libcfs/crypto/crypto.c @@ -379,7 +379,11 @@ EXPORT_SYMBOL(llcrypt_decrypt_block); * Validate dentries in encrypted directories to make sure we aren't potentially * caching stale dentries after a key has been added. */ -static int llcrypt_d_revalidate(struct dentry *dentry, unsigned int flags) +static int llcrypt_d_revalidate( +#ifdef HAVE_D_REVALIDATE_WITH_INODE_NAME + struct inode *inode, const struct qstr *qstr, +#endif + struct dentry *dentry, unsigned int flags) { struct dentry *dir; int err; diff --git a/lustre/include/lustre_compat.h b/lustre/include/lustre_compat.h index 144fa9c..0e3243a 100644 --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -695,7 +695,7 @@ static inline const char *shrinker_debugfs_path(struct shrinker *shrinker) #ifdef HAVE_SEC_RELEASE_SECCTX_1ARG #ifndef HAVE_LSMCONTEXT_INIT /* Ubuntu 5.19 */ -static inline void lsmcontext_init(struct lsmcontext *cp, char *context, +static inline void lsmcontext_init(struct lsm_context *cp, char *context, u32 size, int slot) { #ifdef HAVE_LSMCONTEXT_HAS_ID @@ -713,7 +713,7 @@ static inline void ll_security_release_secctx(char *secdata, u32 seclen, int slot) { #ifdef HAVE_SEC_RELEASE_SECCTX_1ARG - struct lsmcontext context = { }; + struct lsm_context context = { }; lsmcontext_init(&context, secdata, seclen, slot); return security_release_secctx(&context); diff --git a/lustre/include/lvfs.h b/lustre/include/lvfs.h index d0571c8..6eacf0f 100644 --- a/lustre/include/lvfs.h +++ b/lustre/include/lvfs.h @@ -50,8 +50,10 @@ void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx); void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx); #if !defined(HAVE_ALLOC_FILE_PSEUDO) && defined(HAVE_SERVER_SUPPORT) +#ifndef OPEN_FMODE #define OPEN_FMODE(flag) ((__force fmode_t)(((flag + 1) & O_ACCMODE) | \ - (flag & __FMODE_NONOTIFY))) + (flag & FMODE_NONOTIFY))) +#endif static inline struct file *alloc_file_pseudo(struct inode *inode, struct vfsmount *mnt, const char *name, int flags, diff --git a/lustre/llite/dcache.c b/lustre/llite/dcache.c index 634a932..397a63f 100644 --- a/lustre/llite/dcache.c +++ b/lustre/llite/dcache.c @@ -304,7 +304,11 @@ void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry) ll_intent_drop_lock(it); } -static int ll_revalidate_dentry(struct dentry *dentry, +static int ll_revalidate_dentry( +#ifdef HAVE_D_REVALIDATE_WITH_INODE_NAME + struct inode *inode, const struct qstr *qstr, +#endif + struct dentry *dentry, unsigned int lookup_flags) { struct dentry *parent; diff --git a/lustre/llite/xattr_security.c b/lustre/llite/xattr_security.c index fcc8c45..204187b 100644 --- a/lustre/llite/xattr_security.c +++ b/lustre/llite/xattr_security.c @@ -46,7 +46,7 @@ int ll_dentry_init_security(struct dentry *dentry, int mode, struct qstr *name, const char *secctx_name_lsm = NULL; #endif #ifdef HAVE_SECURITY_DENTRY_INIT_SECURTY_WITH_CTX - struct lsmcontext ctx = {}; + struct lsm_context ctx = {}; #endif int rc; diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 773e930..1f755b4 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -6957,7 +6957,7 @@ struct osd_it_ea *osd_it_dir_init(const struct lu_env *env, else file->f_mode |= FMODE_32BITHASH; file->f_path.dentry = obj_dentry; - file->f_flags = O_NOATIME | __FMODE_NONOTIFY; + file->f_flags = O_NOATIME | FMODE_NONOTIFY; file->f_mapping = inode->i_mapping; file->f_op = inode->i_fop; file->f_inode = inode; -- 1.8.3.1