* [PATCH V3] fscrypt: don't set policy for a dead directory
@ 2019-05-22 2:02 ` Hongjie Fang
0 siblings, 0 replies; 6+ messages in thread
From: Hongjie Fang @ 2019-05-22 2:02 UTC (permalink / raw)
To: tytso, jaegeuk, ebiggers; +Cc: linux-fscrypt, Hongjie Fang, stable
the directory maybe has been removed when enter fscrypt_ioctl_set_policy().
if so, the empty_dir() check will return error for ext4 file system.
ext4_rmdir() sets i_size = 0, then ext4_empty_dir() reports an error
because 'inode->i_size < EXT4_DIR_REC_LEN(1) + EXT4_DIR_REC_LEN(2)'.
if the fs is mounted with errors=panic, it will trigger a panic issue.
add the check IS_DEADDIR() to fix this problem.
Fixes: 9bd8212f981e ("ext4 crypto: add encryption policy and password salt support")
Cc: <stable@vger.kernel.org> # v4.1+
Signed-off-by: Hongjie Fang <hongjiefang@asrmicro.com>
---
fs/crypto/policy.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
index d536889..4941fe8 100644
--- a/fs/crypto/policy.c
+++ b/fs/crypto/policy.c
@@ -81,6 +81,8 @@ int fscrypt_ioctl_set_policy(struct file *filp, const void __user *arg)
if (ret == -ENODATA) {
if (!S_ISDIR(inode->i_mode))
ret = -ENOTDIR;
+ else if (IS_DEADDIR(inode))
+ ret = -ENOENT;
else if (!inode->i_sb->s_cop->empty_dir(inode))
ret = -ENOTEMPTY;
else
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH V3] fscrypt: don't set policy for a dead directory
@ 2019-05-22 2:02 ` Hongjie Fang
0 siblings, 0 replies; 6+ messages in thread
From: Hongjie Fang @ 2019-05-22 2:02 UTC (permalink / raw)
To: tytso, jaegeuk, ebiggers; +Cc: linux-fscrypt, Hongjie Fang, stable
the directory maybe has been removed when enter fscrypt_ioctl_set_policy().
if so, the empty_dir() check will return error for ext4 file system.
ext4_rmdir() sets i_size = 0, then ext4_empty_dir() reports an error
because 'inode->i_size < EXT4_DIR_REC_LEN(1) + EXT4_DIR_REC_LEN(2)'.
if the fs is mounted with errors=panic, it will trigger a panic issue.
add the check IS_DEADDIR() to fix this problem.
Fixes: 9bd8212f981e ("ext4 crypto: add encryption policy and password salt support")
Cc: <stable@vger.kernel.org> # v4.1+
Signed-off-by: Hongjie Fang <hongjiefang@asrmicro.com>
---
fs/crypto/policy.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
index d536889..4941fe8 100644
--- a/fs/crypto/policy.c
+++ b/fs/crypto/policy.c
@@ -81,6 +81,8 @@ int fscrypt_ioctl_set_policy(struct file *filp, const void __user *arg)
if (ret == -ENODATA) {
if (!S_ISDIR(inode->i_mode))
ret = -ENOTDIR;
+ else if (IS_DEADDIR(inode))
+ ret = -ENOENT;
else if (!inode->i_sb->s_cop->empty_dir(inode))
ret = -ENOTEMPTY;
else
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH V3] fscrypt: don't set policy for a dead directory
2019-05-22 2:02 ` Hongjie Fang
(?)
@ 2019-05-29 20:50 ` Eric Biggers
-1 siblings, 0 replies; 6+ messages in thread
From: Eric Biggers @ 2019-05-29 20:50 UTC (permalink / raw)
To: Hongjie Fang; +Cc: tytso, jaegeuk, linux-fscrypt, stable
On Wed, May 22, 2019 at 10:02:53AM +0800, Hongjie Fang wrote:
> the directory maybe has been removed when enter fscrypt_ioctl_set_policy().
> if so, the empty_dir() check will return error for ext4 file system.
>
> ext4_rmdir() sets i_size = 0, then ext4_empty_dir() reports an error
> because 'inode->i_size < EXT4_DIR_REC_LEN(1) + EXT4_DIR_REC_LEN(2)'.
> if the fs is mounted with errors=panic, it will trigger a panic issue.
>
> add the check IS_DEADDIR() to fix this problem.
>
> Fixes: 9bd8212f981e ("ext4 crypto: add encryption policy and password salt support")
> Cc: <stable@vger.kernel.org> # v4.1+
> Signed-off-by: Hongjie Fang <hongjiefang@asrmicro.com>
> ---
> fs/crypto/policy.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
> index d536889..4941fe8 100644
> --- a/fs/crypto/policy.c
> +++ b/fs/crypto/policy.c
> @@ -81,6 +81,8 @@ int fscrypt_ioctl_set_policy(struct file *filp, const void __user *arg)
> if (ret == -ENODATA) {
> if (!S_ISDIR(inode->i_mode))
> ret = -ENOTDIR;
> + else if (IS_DEADDIR(inode))
> + ret = -ENOENT;
> else if (!inode->i_sb->s_cop->empty_dir(inode))
> ret = -ENOTEMPTY;
> else
> --
> 1.9.1
>
Applied to fscrypt.git for v5.3.
- Eric
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH V3] fscrypt: don't set policy for a dead directory
2019-05-10 2:05 ` Hongjie Fang
(?)
@ 2019-05-10 12:30 ` Sasha Levin
-1 siblings, 0 replies; 6+ messages in thread
From: Sasha Levin @ 2019-05-10 12:30 UTC (permalink / raw)
To: Sasha Levin, Hongjie Fang, tytso, jaegeuk, ebiggers; +Cc: linux-fscrypt, stable
Hi,
[This is an automated email]
This commit has been processed because it contains a "Fixes:" tag,
fixing commit: 9bd8212f981e ext4 crypto: add encryption policy and password salt support.
The bot has tested the following trees: v5.0.14, v4.19.41, v4.14.117, v4.9.174, v4.4.179.
v5.0.14: Build OK!
v4.19.41: Build OK!
v4.14.117: Build OK!
v4.9.174: Failed to apply! Possible dependencies:
Unable to calculate
v4.4.179: Failed to apply! Possible dependencies:
002ced4be642 ("fscrypto: only allow setting encryption policy on directories")
0b81d0779072 ("fs crypto: move per-file encryption from f2fs tree to fs/crypto")
0cab80ee0c9e ("f2fs: fix to convert inline inode in ->setattr")
0fac2d501b0d ("f2fs crypto: fix spelling typo in comment")
0fd785eb931d ("f2fs: relocate is_merged_page")
1dafa51d45c6 ("f2fs crypto: check for too-short encrypted file names")
36b35a0dbe90 ("f2fs: support data flush in background")
55d1cdb25a81 ("f2fs: relocate tracepoint of write_checkpoint")
6b2553918d8b ("replace ->follow_link() with new method that could stay in RCU mode")
6beceb5427aa ("f2fs: introduce time and interval facility")
8dc0d6a11e7d ("f2fs: early check broken symlink length in the encrypted case")
922ec355f863 ("f2fs crypto: avoid unneeded memory allocation when {en/de}crypting symlink")
9e8925b67a80 ("locks: Allow disabling mandatory locking at compile time")
a263669fa18f ("f2fs crypto: sync with ext4's fname padding")
ae1086686487 ("f2fs crypto: handle unexpected lack of encryption keys")
b9d777b85ff1 ("f2fs: check inline_data flag at converting time")
ce855a3bd092 ("f2fs crypto: f2fs_page_crypto() doesn't need a encryption context")
d0239e1bf520 ("f2fs: detect idle time depending on user behavior")
d323d005ac4a ("f2fs: support file defragment")
dffd0cfa06d4 ("fscrypt: use ENOTDIR when setting encryption policy on nondirectory")
ed3360abbc04 ("f2fs crypto: make sure the encryption info is initialized on opendir(2)")
How should we proceed with this patch?
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH V3] fscrypt: don't set policy for a dead directory
@ 2019-05-10 2:05 ` Hongjie Fang
0 siblings, 0 replies; 6+ messages in thread
From: Hongjie Fang @ 2019-05-10 2:05 UTC (permalink / raw)
To: tytso, jaegeuk, ebiggers; +Cc: linux-fscrypt, Hongjie Fang, stable
the directory maybe has been removed when enter fscrypt_ioctl_set_policy().
it this case, the empty_dir() check will return error for ext4 file system.
ext4_rmdir() sets i_size = 0, then ext4_empty_dir() reports an error
because 'inode->i_size < EXT4_DIR_REC_LEN(1) + EXT4_DIR_REC_LEN(2)'.
if the fs is mounted with errors=panic, it will trigger a panic issue.
add the check IS_DEADDIR() to fix this problem.
Fixes: 9bd8212f981e ("ext4 crypto: add encryption policy and password salt support")
Cc: <stable@vger.kernel.org> # v4.1+
Signed-off-by: Hongjie Fang <hongjiefang@asrmicro.com>
---
fs/crypto/policy.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
index bd7eaf9..a4eca6e 100644
--- a/fs/crypto/policy.c
+++ b/fs/crypto/policy.c
@@ -81,6 +81,8 @@ int fscrypt_ioctl_set_policy(struct file *filp, const void __user *arg)
if (ret == -ENODATA) {
if (!S_ISDIR(inode->i_mode))
ret = -ENOTDIR;
+ else if (IS_DEADDIR(inode))
+ ret = -ENOENT;
else if (!inode->i_sb->s_cop->empty_dir(inode))
ret = -ENOTEMPTY;
else
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH V3] fscrypt: don't set policy for a dead directory
@ 2019-05-10 2:05 ` Hongjie Fang
0 siblings, 0 replies; 6+ messages in thread
From: Hongjie Fang @ 2019-05-10 2:05 UTC (permalink / raw)
To: tytso, jaegeuk, ebiggers; +Cc: linux-fscrypt, Hongjie Fang, stable
the directory maybe has been removed when enter fscrypt_ioctl_set_policy().
it this case, the empty_dir() check will return error for ext4 file system.
ext4_rmdir() sets i_size = 0, then ext4_empty_dir() reports an error
because 'inode->i_size < EXT4_DIR_REC_LEN(1) + EXT4_DIR_REC_LEN(2)'.
if the fs is mounted with errors=panic, it will trigger a panic issue.
add the check IS_DEADDIR() to fix this problem.
Fixes: 9bd8212f981e ("ext4 crypto: add encryption policy and password salt support")
Cc: <stable@vger.kernel.org> # v4.1+
Signed-off-by: Hongjie Fang <hongjiefang@asrmicro.com>
---
fs/crypto/policy.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
index bd7eaf9..a4eca6e 100644
--- a/fs/crypto/policy.c
+++ b/fs/crypto/policy.c
@@ -81,6 +81,8 @@ int fscrypt_ioctl_set_policy(struct file *filp, const void __user *arg)
if (ret == -ENODATA) {
if (!S_ISDIR(inode->i_mode))
ret = -ENOTDIR;
+ else if (IS_DEADDIR(inode))
+ ret = -ENOENT;
else if (!inode->i_sb->s_cop->empty_dir(inode))
ret = -ENOTEMPTY;
else
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-05-29 20:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-22 2:02 [PATCH V3] fscrypt: don't set policy for a dead directory Hongjie Fang
2019-05-22 2:02 ` Hongjie Fang
2019-05-29 20:50 ` Eric Biggers
-- strict thread matches above, loose matches on Subject: below --
2019-05-10 2:05 Hongjie Fang
2019-05-10 2:05 ` Hongjie Fang
2019-05-10 12:30 ` Sasha Levin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.