Re: [RFC PATCH v3 05/16] fscrypt: make fscrypt_fname_disk_to_usr return whether result is nokey name

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

 



On Mon, Sep 14, 2020 at 03:16:56PM -0400, Jeff Layton wrote:
> Ceph will sometimes need to know whether the resulting name from this
> function is a nokey name, in order to set the dentry flags without
> racy checks on the parent inode.
> 
> Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx>
> ---
>  fs/crypto/fname.c       | 5 ++++-
>  fs/crypto/hooks.c       | 4 ++--
>  fs/ext4/dir.c           | 3 ++-
>  fs/ext4/namei.c         | 6 ++++--
>  fs/f2fs/dir.c           | 3 ++-
>  fs/ubifs/dir.c          | 4 +++-
>  include/linux/fscrypt.h | 4 ++--
>  7 files changed, 19 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c
> index 0d41eb4a5493..b97a81ccd838 100644
> --- a/fs/crypto/fname.c
> +++ b/fs/crypto/fname.c
> @@ -353,6 +353,7 @@ EXPORT_SYMBOL(fscrypt_encode_nokey_name);
>   * @oname: output buffer for the user-presentable filename.  The caller must
>   *	   have allocated enough space for this, e.g. using
>   *	   fscrypt_fname_alloc_buffer().
> + * @is_nokey: set to true if oname is a no-key name
>   *
>   * If the key is available, we'll decrypt the disk name.  Otherwise, we'll
>   * encode it for presentation in fscrypt_nokey_name format.
> @@ -363,7 +364,8 @@ EXPORT_SYMBOL(fscrypt_encode_nokey_name);
>  int fscrypt_fname_disk_to_usr(const struct inode *inode,
>  			      u32 hash, u32 minor_hash,
>  			      const struct fscrypt_str *iname,
> -			      struct fscrypt_str *oname)
> +			      struct fscrypt_str *oname,
> +			      bool *is_nokey)
>  {
>  	const struct qstr qname = FSTR_TO_QSTR(iname);
>  	struct fscrypt_nokey_name nokey_name;
> @@ -411,6 +413,7 @@ int fscrypt_fname_disk_to_usr(const struct inode *inode,
>  		size = FSCRYPT_NOKEY_NAME_MAX;
>  	}
>  	oname->len = fscrypt_base64_encode((const u8 *)&nokey_name, size, oname->name);
> +	*is_nokey = true;
>  	return 0;
>  }

Can you do:

	if (is_nokey)
		*is_nokey = true;

... so that callers who don't care can just pass NULL?

Also, to make the kerneldoc clearer:

 * @is_nokey: (output) if non-NULL, set to true if the key wasn't available
 *
 * If the key is available, we'll decrypt the disk name.  Otherwise, we'll
 * encode it for presentation in fscrypt_nokey_name format and set
 * *is_nokey=true.  See struct fscrypt_nokey_name for details.



[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