Re: [PATCH] fscrypt: don't set policy for a dead directory

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

 



Hi,

On Tue, May 07, 2019 at 12:41:48PM +0800, hongjiefang wrote:
> if the directory had been removed, should not set policy for it.
> 
> Signed-off-by: hongjiefang <hongjiefang@xxxxxxxxxxxx>

Can you explain the motivation for this change?  It makes some sense, but I
don't see why it's really needed.  If you look at all the other IS_DEADDIR()
checks in the kernel, they're not for operations on the directory inode itself,
but rather for creating/finding/listing entries in the directory.  I think
FS_IOC_SET_ENCRYPTION_POLICY is more like the former (though it does have to
check whether the directory is empty).

> ---
>  fs/crypto/policy.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
> index bd7eaf9..82900a4 100644
> --- a/fs/crypto/policy.c
> +++ b/fs/crypto/policy.c
> @@ -77,6 +77,12 @@ int fscrypt_ioctl_set_policy(struct file *filp, const void __user *arg)
>  
>  	inode_lock(inode);
>  
> +	/* don't set policy for a dead directory */
> +	if (IS_DEADDIR(inode)) {
> +		ret = -ENOENT;
> +		goto deaddir_out;
> +	}
> +
>  	ret = inode->i_sb->s_cop->get_context(inode, &ctx, sizeof(ctx));
>  	if (ret == -ENODATA) {
>  		if (!S_ISDIR(inode->i_mode))
> @@ -96,6 +102,7 @@ int fscrypt_ioctl_set_policy(struct file *filp, const void __user *arg)
>  		ret = -EEXIST;
>  	}
>  
> +deaddir_out:
>  	inode_unlock(inode);

Call this label 'out_unlock' instead?

>  
>  	mnt_drop_write_file(filp);
> -- 
> 1.9.1
> 

Thanks,

- Eric



[Index of Archives]     [linux Cryptography]     [Asterisk App Development]     [PJ SIP]     [Gnu Gatekeeper]     [IETF Sipping]     [Info Cyrus]     [ALSA User]     [Fedora Linux Users]     [Linux SCTP]     [DCCP]     [Gimp]     [Yosemite News]     [Deep Creek Hot Springs]     [Yosemite Campsites]     [ISDN Cause Codes]

  Powered by Linux