Whamcloud - gitweb
LU-17767 build: struct lsmcontext has slot or id member 81/54881/3
authorSebastien Buisson <sbuisson@ddn.com>
Tue, 23 Apr 2024 17:48:32 +0000 (10:48 -0700)
committerOleg Drokin <green@whamcloud.com>
Tue, 21 May 2024 18:43:25 +0000 (18:43 +0000)
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 <sbuisson@ddn.com>
Change-Id: I5080e60614b42ed63103f93cae1f481851742d0b
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54881
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Aurelien Degremont <adegremont@nvidia.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/autoconf/lustre-core.m4
lustre/include/lustre_compat.h
lustre/llite/xattr_security.c

index a562565..f317739 100644 (file)
@@ -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 <linux/security.h>
+       ],[
+               ((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
index 5f4c497..99d6c8e 100644 (file)
@@ -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;
 }
index df34ab3..8e174a3 100644 (file)
@@ -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) {