From d74d86840056e83cd0138a261ab7b6040a43bfb4 Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Tue, 23 Apr 2024 10:48:32 -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. 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/fs/lustre-release/+/54881 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Aurelien Degremont Reviewed-by: James Simmons Reviewed-by: Shaun Tancheff Reviewed-by: Oleg Drokin --- 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 a562565..f317739 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -3675,6 +3675,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], [ + LB2_MSG_LINUX_TEST_RESULT([if lsmcontext has id], + [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 @@ -4803,6 +4825,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 @@ -5113,6 +5136,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 5f4c497..99d6c8e 100644 --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -774,7 +774,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 df34ab3..8e174a3 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