From 0c34fb4a24d867fcb1cb337b42bc8efdbca08629 Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Mon, 4 Jul 2022 15:31:03 +0200 Subject: [PATCH] EX-5497 sec: fix encrypted symlink length Length of encrypted symlink needs to be the length of the symlink target. To achieve this, we need to read the symlink target and decrypt or decode it in ->getattr(). This is possible thanks to an enhanced getattr capable of getting more stat information. Unfortunately, configure check for kernel support of this enhanced getattr is incomplete, making the code call the basic getattr. Change-Id: I03bf68679a02542b3fb696bb7458ff3276423784 Fixes: ca483b3b85 ("LU-14651 llite: extend inode methods with user namespace arg") Signed-off-by: Sebastien Buisson Reviewed-on: https://review.whamcloud.com/47863 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Jian Yu Reviewed-by: Andreas Dilger --- lustre/llite/symlink.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lustre/llite/symlink.c b/lustre/llite/symlink.c index 3195e75..b2458c7 100644 --- a/lustre/llite/symlink.c +++ b/lustre/llite/symlink.c @@ -258,7 +258,6 @@ static const char *ll_follow_link(struct dentry *dentry, void **cookie) # endif /* HAVE_IOP_GET_LINK */ #endif /* HAVE_SYMLINK_OPS_USE_NAMEIDATA */ -#ifdef HAVE_INODEOPS_ENHANCED_GETATTR /** * ll_getattr_link() - link-specific getattr to set the correct st_size * for encrypted symlinks @@ -280,15 +279,13 @@ static const char *ll_follow_link(struct dentry *dentry, void **cookie) * * Return: 0 on success, -errno on failure */ - +#if defined(HAVE_USER_NAMESPACE_ARG) || defined(HAVE_INODEOPS_ENHANCED_GETATTR) +static int ll_getattr_link( #if defined(HAVE_USER_NAMESPACE_ARG) -static int ll_getattr_link(struct user_namespace *mnt_userns, + struct user_namespace *mnt_userns, +#endif const struct path *path, struct kstat *stat, u32 request_mask, unsigned int flags) -#else -static int ll_getattr_link(const struct path *path, struct kstat *stat, - u32 request_mask, unsigned int flags) -#endif { struct dentry *dentry = path->dentry; struct inode *inode = d_inode(dentry); @@ -319,7 +316,6 @@ static int ll_getattr_link(const struct path *path, struct kstat *stat, #define ll_getattr_link ll_getattr #endif - const struct inode_operations ll_fast_symlink_inode_operations = { #ifdef HAVE_IOP_GENERIC_READLINK .readlink = generic_readlink, -- 1.8.3.1