if the directory had been removed, should not set policy for it. Signed-off-by: hongjiefang <hongjiefang@xxxxxxxxxxxx> --- 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); mnt_drop_write_file(filp); -- 1.9.1