[lustre-devel] [PATCH 08/25] lustre: enc: make sure DoM files are correctly decrypted
James Simmons
jsimmons at infradead.org
Thu Jan 30 06:10:58 PST 2025
From: Sebastien Buisson <sbuisson at ddn.com>
Make sure DoM files are decrypted upon read by loading their
associated encryption context, via fscrypt_prepare_readdir()/
fscrypt_get_encryption_info().
WC-bug-id: https://jira.whamcloud.com/browse/LU-16670
Lustre-commit: 1c424252d37c64e3c ("LU-16670 enc: make sure DoM files are correctly decrypted")
Signed-off-by: Sebastien Buisson <sbuisson at ddn.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50429
Reviewed-by: Andreas Dilger <adilger at whamcloud.com>
Reviewed-by: Patrick Farrell <pfarrell at whamcloud.com>
Reviewed-by: Mikhail Pershin <mpershin at whamcloud.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
fs/lustre/llite/file.c | 7 +++++--
fs/lustre/llite/namei.c | 6 +-----
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/fs/lustre/llite/file.c b/fs/lustre/llite/file.c
index 9307007c3e18..d196362a40ca 100644
--- a/fs/lustre/llite/file.c
+++ b/fs/lustre/llite/file.c
@@ -453,14 +453,13 @@ static inline int ll_dom_readpage(void *data, struct page *page)
if (lnb->lnb_len < PAGE_SIZE)
memset(kaddr + lnb->lnb_len, 0,
PAGE_SIZE - lnb->lnb_len);
- flush_dcache_page(page);
- SetPageUptodate(page);
kunmap_atomic(kaddr);
if (inode && IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode)) {
if (!fscrypt_has_encryption_key(inode)) {
CDEBUG(D_SEC, "no enc key for " DFID "\n",
PFID(ll_inode2fid(inode)));
+ rc = -ENOKEY;
} else {
unsigned int offs = 0;
@@ -481,6 +480,10 @@ static inline int ll_dom_readpage(void *data, struct page *page)
}
}
}
+ if (!rc) {
+ flush_dcache_page(page);
+ SetPageUptodate(page);
+ }
unlock_page(page);
return rc;
diff --git a/fs/lustre/llite/namei.c b/fs/lustre/llite/namei.c
index a19e5f707027..920b592489ab 100644
--- a/fs/lustre/llite/namei.c
+++ b/fs/lustre/llite/namei.c
@@ -735,10 +735,6 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request,
rc = fscrypt_get_encryption_info(inode);
if (rc)
goto out;
- if (!fscrypt_has_encryption_key(inode)) {
- rc = -ENOKEY;
- goto out;
- }
}
} else if (!it_disposition(it, DISP_OPEN_CREATE)) {
/*
@@ -1204,6 +1200,7 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry,
rc = fscrypt_get_encryption_info(dir);
if (rc)
goto out_release;
+ encrypt = true;
if (open_flags & O_CREAT) {
/* For migration or mirroring without enc key, we still
* need to be able to create a volatile file.
@@ -1216,7 +1213,6 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry,
rc = -ENOKEY;
goto out_release;
}
- encrypt = true;
}
}
--
2.39.3
More information about the lustre-devel
mailing list