From 88bccc4fa4dd7310560f588c730eefedf423c515 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 Test-Parameters: trivial HPE-bug-id: LUS-11188 Signed-off-by: Shaun Tancheff Change-Id: I42d3307f7fe0d2412381363f60ac5b3df2d5891a Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48359 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin Reviewed-by: Petros Koutoupis Reviewed-by: Sebastien Buisson --- lustre/autoconf/lustre-core.m4 | 31 +++++++++++++++++++++++++++++++ lustre/llite/xattr_security.c | 9 +++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index aa0e174..f3ee56f 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -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 +],[ + 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 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