Whamcloud - gitweb
LU-16114 build: Update security_dentry_init_security args
authorShaun Tancheff <shaun.tancheff@hpe.com>
Sun, 28 Aug 2022 14:38:39 +0000 (21:38 +0700)
committerAndreas Dilger <adilger@whamcloud.com>
Tue, 17 Jan 2023 19:39:24 +0000 (19:39 +0000)
Linux commit v5.15-rc1-20-g15bf32398ad4
   security: Return xattr name from security_dentry_init_security()

Adjust security_dentry_init_security() calls accordingly

Lustre-change: https://review.whamcloud.com/48359
Lustre-commit: 88bccc4fa4dd7310560f588c730eefedf423c515

Test-Parameters: trivial
HPE-bug-id: LUS-11188
Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Change-Id: I42d3307f7fe0d2412381363f60ac5b3df2d5891a
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/49627
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/autoconf/lustre-core.m4
lustre/llite/xattr_security.c

index c0e7c4f..b41ea0c 100644 (file)
@@ -2653,6 +2653,36 @@ get_acl_rcu_argument, [
 EXTRA_KCFLAGS="$tmp_flags"
 ]) # LC_HAVE_GET_ACL_RCU_ARG
 
+#
+# LC_HAVE_SECURITY_DENTRY_INIT_WITH_XATTR_NAME_ARG
+#
+# Linux v5.15-rc1-20-g15bf32398ad4
+# security: Return xattr name from security_dentry_init_security()
+#
+AC_DEFUN([LC_HAVE_SECURITY_DENTRY_INIT_WITH_XATTR_NAME_ARG], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if security_dentry_init_security() returns xattr name],
+security_dentry_init_security_xattr_name_arg, [
+       #include <linux/security.h>
+],[
+       struct dentry *dentry = NULL;
+       int mode = 0;
+       const struct qstr *name = NULL;
+       const char *xattr_name = NULL;
+       void **ctx = NULL;
+       u32 *ctxlen = 0;
+       int rc = security_dentry_init_security(dentry, mode, name, &xattr_name,
+                                              ctx, ctxlen);
+       (void)rc;
+
+],[
+       AC_DEFINE(HAVE_SECURITY_DENTRY_INIT_WITH_XATTR_NAME_ARG, 1,
+               [security_dentry_init_security() returns xattr name])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LC_HAVE_SECURITY_DENTRY_INIT_WITH_XATTR_NAME_ARG
+
 AC_DEFUN([LC_PROG_LINUX_SRC], [])
 AC_DEFUN([LC_PROG_LINUX_RESULTS], [])
 
@@ -2853,6 +2883,9 @@ AC_DEFUN([LC_PROG_LINUX], [
        # 5.15
        LC_HAVE_GET_ACL_RCU_ARG
 
+       # 5.16
+       LC_HAVE_SECURITY_DENTRY_INIT_WITH_XATTR_NAME_ARG
+
        # kernel patch to extend integrity interface
        LC_BIO_INTEGRITY_PREP_FN
 
index caf89be..9bcb800 100644 (file)
@@ -83,8 +83,11 @@ int ll_dentry_init_security(struct inode *parent, struct dentry *dentry,
        if (rc != strlen(XATTR_NAME_SELINUX) + 1)
                return -EOPNOTSUPP;
 
-       rc = security_dentry_init_security(dentry, mode, name, secctx,
-                                          secctx_size);
+       rc = security_dentry_init_security(dentry, mode, name,
+#ifdef HAVE_SECURITY_DENTRY_INIT_WITH_XATTR_NAME_ARG
+                                          secctx_name,
+#endif
+                                          secctx, secctx_size);
        /* Usually, security_dentry_init_security() returns -EOPNOTSUPP when
         * SELinux is disabled.
         * But on some kernels (e.g. rhel 8.5) it returns 0 when SELinux is
@@ -96,7 +99,9 @@ int ll_dentry_init_security(struct inode *parent, struct dentry *dentry,
        if (rc < 0)
                return rc;
 
+#ifndef HAVE_SECURITY_DENTRY_INIT_WITH_XATTR_NAME_ARG
        *secctx_name = XATTR_NAME_SELINUX;
+#endif
 
        return 0;
 }