diff mbox series

[v14,25/64] ceph: set DCACHE_NOKEY_NAME in atomic open

Message ID 20220427191314.222867-26-jlayton@kernel.org
State New
Headers show
Series [v14,01/64] libceph: add spinlock around osd->o_requests | expand

Commit Message

Jeff Layton April 27, 2022, 7:12 p.m. UTC
Atomic open can act as a lookup if handed a dentry that is negative on
the MDS. Ensure that we set DCACHE_NOKEY_NAME on the dentry in
atomic_open, if we don't have the key for the parent. Otherwise, we can
end up validating the dentry inappropriately if someone later adds a
key.

Reviewed-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Luís Henriques <lhenriques@suse.de>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ceph/file.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 391de38fa489..a519218ef942 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -768,6 +768,13 @@  int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
 	req->r_args.open.mask = cpu_to_le32(mask);
 	req->r_parent = dir;
 	ihold(dir);
+	if (IS_ENCRYPTED(dir)) {
+		if (!fscrypt_has_encryption_key(dir)) {
+			spin_lock(&dentry->d_lock);
+			dentry->d_flags |= DCACHE_NOKEY_NAME;
+			spin_unlock(&dentry->d_lock);
+		}
+	}
 
 	if (flags & O_CREAT) {
 		struct ceph_file_layout lo;