From b325e810b76b6e25a842468fab4724610ecc5bc1 Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Sun, 28 Aug 2022 21:38:39 +0700 Subject: [PATCH] LU-16114 build: Update security_dentry_init_security args 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 Change-Id: I42d3307f7fe0d2412381363f60ac5b3df2d5891a Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/49627 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/autoconf/lustre-core.m4 | 33 +++++++++++++++++++++++++++++++++ lustre/llite/xattr_security.c | 9 +++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index c0e7c4f..b41ea0c 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -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 +],[ + 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 diff --git a/lustre/llite/xattr_security.c b/lustre/llite/xattr_security.c index caf89be..9bcb800 100644 --- a/lustre/llite/xattr_security.c +++ b/lustre/llite/xattr_security.c @@ -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; } -- 1.8.3.1