From 97c78562da39b03070f5e71d6010b51de59b8a0a Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Tue, 6 Dec 2022 17:36:02 +0100 Subject: [PATCH] LU-16369 ldiskfs: do not check enc context at lookup On rhel8, ldiskfs should not check for encryption context of inodes upon lookup. On these kernels, ext4 is not encryption aware, so just assume context is fine when target is mounted as ldiskfs. Lustre-change: https://review.whamcloud.com/49324 Lustre-commit: 540c293a4d0fc80253670b3db8d6722da43284ad Signed-off-by: Sebastien Buisson Change-Id: I9f9813d290ea24b34f710e2c8219e856ca8fbc58 Reviewed-by: Andreas Dilger Reviewed-by: Li Dongyang Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/49894 Tested-by: jenkins Tested-by: Maloo --- .../patches/rhel8.5/ext4-filename-encode.patch | 19 ++++++++++++++++++- .../patches/rhel8.7/ext4-filename-encode.patch | 19 ++++++++++++++++++- .../patches/rhel8/ext4-filename-encode.patch | 19 ++++++++++++++++++- 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/ldiskfs/kernel_patches/patches/rhel8.5/ext4-filename-encode.patch b/ldiskfs/kernel_patches/patches/rhel8.5/ext4-filename-encode.patch index 6351670..582f6b7 100644 --- a/ldiskfs/kernel_patches/patches/rhel8.5/ext4-filename-encode.patch +++ b/ldiskfs/kernel_patches/patches/rhel8.5/ext4-filename-encode.patch @@ -1,7 +1,7 @@ diff -wur /dev/null b/fs/ext4/critical_encode.h --- /dev/null +++ b/fs/ext4/critical_encode.h -@@ -0,0 +1,158 @@ +@@ -0,0 +1,166 @@ +/* + * critical_encode.h + * @@ -78,6 +78,14 @@ diff -wur /dev/null b/fs/ext4/critical_encode.h +#define fscrypt_get_encryption_info(inode) \ + (unlikely(!IS_LUSTRE_MOUNT(inode->i_sb)) ? 0 : -EOPNOTSUPP) + ++static inline int ext4_has_permitted_context(struct inode *parent, ++ struct inode *child) ++{ ++ if (unlikely(!IS_LUSTRE_MOUNT(parent->i_sb))) ++ return 1; ++ return fscrypt_has_permitted_context(parent, child); ++} ++ +static inline int ext4_prepare_lookup(struct inode *dir, + struct dentry *dentry, + unsigned int flags) @@ -357,6 +365,15 @@ diff -wur a/fs/ext4/namei.c b/fs/ext4/namei.c if (err) return ERR_PTR(err); +@@ -1957,7 +1957,7 @@ static struct dentry *ext4_lookup(struct + } + if (!IS_ERR(inode) && IS_ENCRYPTED(dir) && + (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) && +- !fscrypt_has_permitted_context(dir, inode)) { ++ !ext4_has_permitted_context(dir, inode)) { + ext4_warning(inode->i_sb, + "Inconsistent encryption contexts: %lu/%lu", + dir->i_ino, inode->i_ino); @@ -2206,7 +2221,7 @@ int ext4_find_dest_de(struct inode *d if (ext4_check_dir_entry(dir, NULL, de, bh, buf, buf_size, offset)) diff --git a/ldiskfs/kernel_patches/patches/rhel8.7/ext4-filename-encode.patch b/ldiskfs/kernel_patches/patches/rhel8.7/ext4-filename-encode.patch index 7dc0528..2551bbd 100644 --- a/ldiskfs/kernel_patches/patches/rhel8.7/ext4-filename-encode.patch +++ b/ldiskfs/kernel_patches/patches/rhel8.7/ext4-filename-encode.patch @@ -1,7 +1,7 @@ diff -wur /dev/null b/fs/ext4/critical_encode.h --- /dev/null +++ b/fs/ext4/critical_encode.h -@@ -0,0 +1,158 @@ +@@ -0,0 +1,166 @@ +/* + * critical_encode.h + * @@ -78,6 +78,14 @@ diff -wur /dev/null b/fs/ext4/critical_encode.h +#define fscrypt_get_encryption_info(inode) \ + (unlikely(!IS_LUSTRE_MOUNT(inode->i_sb)) ? 0 : -EOPNOTSUPP) + ++static inline int ext4_has_permitted_context(struct inode *parent, ++ struct inode *child) ++{ ++ if (unlikely(!IS_LUSTRE_MOUNT(parent->i_sb))) ++ return 1; ++ return fscrypt_has_permitted_context(parent, child); ++} ++ +static inline int ext4_prepare_lookup(struct inode *dir, + struct dentry *dentry, + unsigned int flags) @@ -358,6 +366,15 @@ Index: kernel-4.18.0-423.el8/fs/ext4/namei.c if (err) return ERR_PTR(err); +@@ -1957,7 +1957,7 @@ static struct dentry *ext4_lookup(struct + } + if (!IS_ERR(inode) && IS_ENCRYPTED(dir) && + (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) && +- !fscrypt_has_permitted_context(dir, inode)) { ++ !ext4_has_permitted_context(dir, inode)) { + ext4_warning(inode->i_sb, + "Inconsistent encryption contexts: %lu/%lu", + dir->i_ino, inode->i_ino); @@ -2271,7 +2296,7 @@ int ext4_find_dest_de(struct inode *dir, if (ext4_check_dir_entry(dir, NULL, de, bh, buf, buf_size, offset)) diff --git a/ldiskfs/kernel_patches/patches/rhel8/ext4-filename-encode.patch b/ldiskfs/kernel_patches/patches/rhel8/ext4-filename-encode.patch index 728ffa8..7a9f591 100644 --- a/ldiskfs/kernel_patches/patches/rhel8/ext4-filename-encode.patch +++ b/ldiskfs/kernel_patches/patches/rhel8/ext4-filename-encode.patch @@ -1,7 +1,7 @@ diff -wur /dev/null b/fs/ext4/critical_encode.h --- /dev/null +++ b/fs/ext4/critical_encode.h -@@ -0,0 +1,158 @@ +@@ -0,0 +1,166 @@ +/* + * critical_encode.h + * @@ -78,6 +78,14 @@ diff -wur /dev/null b/fs/ext4/critical_encode.h +#define fscrypt_get_encryption_info(inode) \ + (unlikely(!IS_LUSTRE_MOUNT(inode->i_sb)) ? 0 : -EOPNOTSUPP) + ++static inline int ext4_has_permitted_context(struct inode *parent, ++ struct inode *child) ++{ ++ if (unlikely(!IS_LUSTRE_MOUNT(parent->i_sb))) ++ return 1; ++ return fscrypt_has_permitted_context(parent, child); ++} ++ +static inline int ext4_prepare_lookup(struct inode *dir, + struct dentry *dentry, + unsigned int flags) @@ -357,6 +365,15 @@ diff -wur a/fs/ext4/namei.c b/fs/ext4/namei.c if (err) return ERR_PTR(err); +@@ -1957,7 +1957,7 @@ static struct dentry *ext4_lookup(struct + } + if (!IS_ERR(inode) && IS_ENCRYPTED(dir) && + (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) && +- !fscrypt_has_permitted_context(dir, inode)) { ++ !ext4_has_permitted_context(dir, inode)) { + ext4_warning(inode->i_sb, + "Inconsistent encryption contexts: %lu/%lu", + dir->i_ino, inode->i_ino); @@ -2206,7 +2221,7 @@ int ext4_find_dest_de(struct inode *d if (ext4_check_dir_entry(dir, NULL, de, bh, buf, buf_size, offset)) -- 1.8.3.1