]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
ceph: set DCACHE_NOKEY_NAME in atomic open
authorJeff Layton <jlayton@kernel.org>
Mon, 28 Mar 2022 20:18:38 +0000 (16:18 -0400)
committerJeff Layton <jlayton@kernel.org>
Tue, 31 May 2022 15:49:59 +0000 (11:49 -0400)
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 <lhenriques@suse.de>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
fs/ceph/file.c

index 0c13a3f23c99b79ff31be87ebcfd11762a229e70..31798888212b171892d88a325068f5ba01d21333 100644 (file)
@@ -773,6 +773,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;