Re: [RFC PATCH v3 10/16] ceph: add routine to create context prior to RPC

Eric Biggers
2020-09-15T01:37:33Z

On Mon, Sep 14, 2020 at 03:17:01PM -0400, Jeff Layton wrote:
> diff --git a/fs/ceph/crypto.h b/fs/ceph/crypto.h
> index b5f38ee80553..c1b6ec4b2961 100644
> --- a/fs/ceph/crypto.h
> +++ b/fs/ceph/crypto.h
> @@ -11,6 +11,8 @@
> #define CEPH_XATTR_NAME_ENCRYPTION_CONTEXT "encryption.ctx"
>
> void ceph_fscrypt_set_ops(struct super_block *sb);
> +int ceph_fscrypt_prepare_context(struct inode *dir, struct inode *inode,
> + struct ceph_acl_sec_ctx *as);
>
> #else /* CONFIG_FS_ENCRYPTION */
>
> @@ -19,6 +21,12 @@ static inline int ceph_fscrypt_set_ops(struct super_block *sb)
> return 0;
> }
>
> +static inline int ceph_fscrypt_prepare_context(struct inode *dir, struct inode *inode,
> + struct ceph_acl_sec_ctx *as)
> +{
> + return 0;
> +}
> +
> #endif /* CONFIG_FS_ENCRYPTION */

Seems there should at least be something that prevents you from creating a file
in an encrypted directory when !CONFIG_FS_ENCRYPTION.

The other filesystems use fscrypt_prepare_new_inode() for this; it returns
EOPNOTSUPP when IS_ENCRYPTED(dir).

- Eric