Re: [RFC PATCH v2 11/18] ceph: add routine to create context prior to RPC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Sep 04, 2020 at 12:05:30PM -0400, Jeff Layton wrote:
> After pre-creating a new inode, do an fscrypt prepare on it, fetch a
> new encryption context and then marshal that into the security context
> to be sent along with the RPC.
> 
> Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx>
> ---
>  fs/ceph/crypto.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++
>  fs/ceph/crypto.h |  8 ++++++
>  fs/ceph/inode.c  | 10 ++++++--
>  fs/ceph/super.h  |  3 +++
>  4 files changed, 82 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/ceph/crypto.c b/fs/ceph/crypto.c
> index 22a09d422b72..f4849f8b32df 100644
> --- a/fs/ceph/crypto.c
> +++ b/fs/ceph/crypto.c
> @@ -67,3 +67,66 @@ int ceph_fscrypt_set_ops(struct super_block *sb)
>  	}
>  	return 0;
>  }
> +
> +int ceph_fscrypt_prepare_context(struct inode *dir, struct inode *inode,
> +				 struct ceph_acl_sec_ctx *as)
> +{
> +	int ret, ctxsize;
> +	size_t name_len;
> +	char *name;
> +	struct ceph_pagelist *pagelist = as->pagelist;
> +	bool encrypted = false;
> +
> +	ret = fscrypt_prepare_new_inode(dir, inode, &encrypted);
> +	if (ret)
> +		return ret;
> +	if (!encrypted)
> +		return 0;
> +
> +	inode_set_flags(inode, S_ENCRYPTED, S_ENCRYPTED);

This is a new inode, so 'inode->i_flags |= S_ENCRYPTED' would be sufficient.

> +
> +	/* No need to set context for dummy encryption */
> +	if (fscrypt_get_dummy_context(inode->i_sb))
> +		return 0;

This isn't correct.  When test_dummy_encryption causes a new inode to be
automatically encrypted, the inode's encryption context is still supposed to be
saved to disk.

Also, when the filesystem is mounted with test_dummy_encryption, there may
already be existing encrypted directories that were created via the regular path
(not via test_dummy_encryption).  Those should keep working as expected.  That
likewise requires saving new encryption contexts to disk.

- Eric



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux