summaryrefslogtreecommitdiffstats
path: root/fs/ceph/crypto.h
diff options
context:
space:
mode:
authorXiubo Li <xiubli@redhat.com>2022-03-14 10:28:35 +0800
committerIlya Dryomov <idryomov@gmail.com>2023-08-24 11:24:34 +0200
commitaf9ffa6df7e337599ce41165d9e6166a330c7b96 (patch)
treee62445c27ebbdba422319064f1ff141ca03b82ea /fs/ceph/crypto.h
parent3859af9eba958cec91e4908f64787f190254f565 (diff)
downloadlinux-af9ffa6df7e337599ce41165d9e6166a330c7b96.tar.gz
linux-af9ffa6df7e337599ce41165d9e6166a330c7b96.tar.bz2
linux-af9ffa6df7e337599ce41165d9e6166a330c7b96.zip
ceph: add support to readdir for encrypted names
To make it simpler to decrypt names in a readdir reply (i.e. before we have a dentry), add a new ceph_encode_encrypted_fname()-like helper that takes a qstr pointer instead of a dentry pointer. Once we've decrypted the names in a readdir reply, we no longer need the crypttext, so overwrite them in ceph_mds_reply_dir_entry with the unencrypted names. Then in both ceph_readdir_prepopulate() and ceph_readdir() we will use the dencrypted name directly. [ jlayton: convert some BUG_ONs into error returns ] Signed-off-by: Xiubo Li <xiubli@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Reviewed-and-tested-by: Luís Henriques <lhenriques@suse.de> Reviewed-by: Milind Changire <mchangir@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'fs/ceph/crypto.h')
-rw-r--r--fs/ceph/crypto.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/ceph/crypto.h b/fs/ceph/crypto.h
index a53645123248..3269fc8f8cf3 100644
--- a/fs/ceph/crypto.h
+++ b/fs/ceph/crypto.h
@@ -19,6 +19,7 @@ struct ceph_fname {
unsigned char *ctext; // binary crypttext (if any)
u32 name_len; // length of name buffer
u32 ctext_len; // length of crypttext
+ bool no_copy;
};
struct ceph_fscrypt_auth {
@@ -76,6 +77,8 @@ int ceph_fscrypt_prepare_context(struct inode *dir, struct inode *inode,
struct ceph_acl_sec_ctx *as);
void ceph_fscrypt_as_ctx_to_req(struct ceph_mds_request *req,
struct ceph_acl_sec_ctx *as);
+int ceph_encode_encrypted_dname(const struct inode *parent,
+ struct qstr *d_name, char *buf);
int ceph_encode_encrypted_fname(const struct inode *parent,
struct dentry *dentry, char *buf);
@@ -121,6 +124,13 @@ static inline void ceph_fscrypt_as_ctx_to_req(struct ceph_mds_request *req,
{
}
+static inline int ceph_encode_encrypted_dname(const struct inode *parent,
+ struct qstr *d_name, char *buf)
+{
+ memcpy(buf, d_name->name, d_name->len);
+ return d_name->len;
+}
+
static inline int ceph_encode_encrypted_fname(const struct inode *parent,
struct dentry *dentry, char *buf)
{