From 3cf18ea91cfdabd242c08cca60dabe4c5d68b372 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Mon, 28 Mar 2022 16:18:38 -0400 Subject: [PATCH] ceph: set DCACHE_NOKEY_NAME in atomic open MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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: Luís Henriques Reviewed-by: Xiubo Li Signed-off-by: Jeff Layton --- fs/ceph/file.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/ceph/file.c b/fs/ceph/file.c index d6a244a239c7..04a2cc39da2d 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -779,6 +779,13 @@ retry: 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; -- 2.47.3