Whamcloud - gitweb
LU-16114 build: Update security_dentry_init_security args 59/48359/6
authorShaun Tancheff <shaun.tancheff@hpe.com>
Sun, 28 Aug 2022 14:38:39 +0000 (21:38 +0700)
committerOleg Drokin <green@whamcloud.com>
Tue, 13 Dec 2022 16:06:42 +0000 (16:06 +0000)
Linux commit v5.15-rc1-20-g15bf32398ad4
   security: Return xattr name from security_dentry_init_security()

Adjust security_dentry_init_security() calls accordingly

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/fs/lustre-release/+/48359
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Petros Koutoupis <petros.koutoupis@hpe.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
lustre/autoconf/lustre-core.m4
lustre/llite/xattr_security.c

index aa0e174..f3ee56f 100644 (file)
@@ -2762,6 +2762,36 @@ 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
+
+#
 # LC_HAVE_KIOCB_COMPLETE_2ARGS
 #
 # kernel v5.15-rc6-145-g6b19b766e8f0
@@ -2999,6 +3029,7 @@ AC_DEFUN([LC_PROG_LINUX], [
        LC_HAVE_GET_ACL_RCU_ARG
 
        # 5.16
+       LC_HAVE_SECURITY_DENTRY_INIT_WITH_XATTR_NAME_ARG
        LC_HAVE_KIOCB_COMPLETE_2ARGS
 
        # kernel patch to extend integrity interface
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;
 }