[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <27801620-b3fd-d556-c100-409632f91661@redhat.com>
Date: Fri, 25 Feb 2022 13:36:24 +0800
From: Xiubo Li <xiubli@...hat.com>
To: Luís Henriques <lhenriques@...e.de>,
Jeff Layton <jlayton@...nel.org>,
Ilya Dryomov <idryomov@...il.com>
Cc: ceph-devel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH] ceph: add support for encrypted snapshot names
On 2/24/22 7:21 PM, Luís Henriques wrote:
> Since filenames in encrypted directories are already encrypted and shown
> as a base64-encoded string when the directory is locked, snapshot names
> should show a similar behaviour.
>
> Signed-off-by: Luís Henriques <lhenriques@...e.de>
> ---
> fs/ceph/dir.c | 15 +++++++++++++++
> fs/ceph/inode.c | 10 +++++++++-
> 2 files changed, 24 insertions(+), 1 deletion(-)
>
> Support on the MDS for names that'll be > MAX_NAME when base64 encoded is
> still TBD. I thought it would be something easy to do, but snapshots
> don't seem to make use of the CDir/CDentry (which is where alternate_name
> is stored on the MDS). I'm still looking into this, but I may need some
> help there :-(
Yeah, good catch. The snapshot handler in MDS hasn't handled this case
yet, though the kclient has passed it to MDS server.
The snapshot alternate_name raw ciphertext should be stored in SnapInfo
struct along with the 'name'.
>
> Cheers,
> --
> Luís
>
> diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
> index a449f4a07c07..20ae600ee7cd 100644
> --- a/fs/ceph/dir.c
> +++ b/fs/ceph/dir.c
> @@ -1065,6 +1065,13 @@ static int ceph_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
> op = CEPH_MDS_OP_MKSNAP;
> dout("mksnap dir %p snap '%pd' dn %p\n", dir,
> dentry, dentry);
> + /* XXX missing support for alternate_name in snapshots */
> + if (IS_ENCRYPTED(dir) && (dentry->d_name.len >= 189)) {
> + dout("encrypted snapshot name too long: %pd len: %d\n",
> + dentry, dentry->d_name.len);
> + err = -ENAMETOOLONG;
> + goto out;
> + }
We should fix the MDS side bug and then this workaroud will be no needed.
- Xiubo
> } else if (ceph_snap(dir) == CEPH_NOSNAP) {
> dout("mkdir dir %p dn %p mode 0%ho\n", dir, dentry, mode);
> op = CEPH_MDS_OP_MKDIR;
> @@ -1109,6 +1116,14 @@ static int ceph_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
> !req->r_reply_info.head->is_target &&
> !req->r_reply_info.head->is_dentry)
> err = ceph_handle_notrace_create(dir, dentry);
> +
> + /*
> + * If we have created a snapshot we need to clear the cache, otherwise
> + * snapshot will show encrypted filenames in readdir.
> + */
> + if (ceph_snap(dir) == CEPH_SNAPDIR)
> + d_drop(dentry);
> +
> out_req:
> ceph_mdsc_put_request(req);
> out:
> diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
> index 8b0832271fdf..080824610b73 100644
> --- a/fs/ceph/inode.c
> +++ b/fs/ceph/inode.c
> @@ -182,6 +182,13 @@ struct inode *ceph_get_snapdir(struct inode *parent)
> ci->i_rbytes = 0;
> ci->i_btime = ceph_inode(parent)->i_btime;
>
> + /* if encrypted, just borough fscrypt_auth from parent */
> + if (IS_ENCRYPTED(parent)) {
> + struct ceph_inode_info *pci = ceph_inode(parent);
> + inode->i_flags |= S_ENCRYPTED;
> + ci->fscrypt_auth_len = pci->fscrypt_auth_len;
> + ci->fscrypt_auth = pci->fscrypt_auth;
> + }
> if (inode->i_state & I_NEW) {
> inode->i_op = &ceph_snapdir_iops;
> inode->i_fop = &ceph_snapdir_fops;
> @@ -632,7 +639,8 @@ void ceph_free_inode(struct inode *inode)
>
> kfree(ci->i_symlink);
> #ifdef CONFIG_FS_ENCRYPTION
> - kfree(ci->fscrypt_auth);
> + if (ceph_snap(inode) != CEPH_SNAPDIR)
> + kfree(ci->fscrypt_auth);
> #endif
> fscrypt_free_inode(inode);
> kmem_cache_free(ceph_inode_cachep, ci);
>
Powered by blists - more mailing lists