From 962e98a7034bf177a7081b32fafef5a3d55a362e Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Tue, 23 Apr 2024 12:03:19 -0700 Subject: [PATCH] LU-17767 build: struct lsmcontext has slot or id member With Ubuntu 24.04 kernel 6.8.0-31-generic, the struct lsmcontext uses a field named 'id' to identify the LSM module, instead of 'slot' in previous kernel versions. Lustre-change: https://review.whamcloud.com/54881 Lustre-commit: TBD (from 7764f73b8e25f8658867e7ab080fe5d8ec62230b) Fixes: 0e66489401 ("LU-16619 build: Ubuntu jammy 5.19 client support") Test-Parameters: trivial Signed-off-by: Sebastien Buisson Change-Id: I5080e60614b42ed63103f93cae1f481851742d0b Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/54882 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/autoconf/lustre-core.m4 | 24 ++++++++++++++++++++++++ lustre/include/lustre_compat.h | 4 ++++ lustre/llite/xattr_security.c | 6 +++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 4989ba9..60ef94e 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -3326,6 +3326,28 @@ AC_DEFUN([LC_SECURITY_DENTRY_INIT_SECURTY_WITH_CTX], [ ]) # LC_SECURITY_DENTRY_INIT_SECURTY_WITH_CTX # +# LC_LSMCONTEXT_HAS_ID +# +# repo: git://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/noble +# commit dad7cffb719e45fd43121ade4ada90ff376c9cad +# LSM stacking v39: LSM: Ensure the correct LSM context releaser +# +AC_DEFUN([LC_SRC_LSMCONTEXT_HAS_ID], [ + LB2_LINUX_TEST_SRC([lsmcontext_has_id], [ + #include + ],[ + ((struct lsmcontext *)1)->id = 0; + ],[-Werror]) +]) +AC_DEFUN([LC_LSMCONTEXT_HAS_ID], [ + AC_MSG_CHECKING([if lsmcontext has id]) + LB2_LINUX_TEST_RESULT([lsmcontext_has_id], [ + AC_DEFINE(HAVE_LSMCONTEXT_HAS_ID, 1, + [lsmcontext has id]) + ]) +]) # LC_LSMCONTEXT_HAS_ID + +# # LC_HAVE_NO_LLSEEK # # Linux commit v5.19-rc2-6-g868941b14441 @@ -4437,6 +4459,7 @@ AC_DEFUN([LC_PROG_LINUX_SRC], [ # 6.8 LC_SRC_HAVE_DENTRY_D_CHILDREN LC_SRC_HAVE_GENERIC_ERROR_REMOVE_FOLIO + LC_SRC_LSMCONTEXT_HAS_ID # kernel patch to extend integrity interface LC_SRC_BIO_INTEGRITY_PREP_FN @@ -4722,6 +4745,7 @@ AC_DEFUN([LC_PROG_LINUX_RESULTS], [ # 6.8 LC_HAVE_DENTRY_D_CHILDREN LC_HAVE_GENERIC_ERROR_REMOVE_FOLIO + LC_LSMCONTEXT_HAS_ID # kernel patch to extend integrity interface LC_BIO_INTEGRITY_PREP_FN diff --git a/lustre/include/lustre_compat.h b/lustre/include/lustre_compat.h index 02708c9..e306084 100644 --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -664,7 +664,11 @@ ll_shrinker_create(struct ll_shrinker_ops *ops, unsigned int flags, static inline void lsmcontext_init(struct lsmcontext *cp, char *context, u32 size, int slot) { +#ifdef HAVE_LSMCONTEXT_HAS_ID + cp->id = slot; +#else cp->slot = slot; +#endif cp->context = context; cp->len = size; } diff --git a/lustre/llite/xattr_security.c b/lustre/llite/xattr_security.c index e44c04a..a95141a 100644 --- a/lustre/llite/xattr_security.c +++ b/lustre/llite/xattr_security.c @@ -102,8 +102,12 @@ int ll_dentry_init_security(struct dentry *dentry, int mode, struct qstr *name, #ifdef HAVE_SECURITY_DENTRY_INIT_SECURTY_WITH_CTX *secctx = ctx.context; *secctx_size = ctx.len; +#ifdef HAVE_LSMCONTEXT_HAS_ID + *secctx_slot = ctx.id; +#else *secctx_slot = ctx.slot; -#endif +#endif /* HAVE_LSMCONTEXT_HAS_ID */ +#endif /* HAVE_SECURITY_DENTRY_INIT_SECURTY_WITH_CTX */ #ifdef HAVE_SECURITY_DENTRY_INIT_WITH_XATTR_NAME_ARG if (strncmp(*secctx_name, secctx_name_lsm, *secctx_name_size) != 0) { -- 1.8.3.1