diff mbox series

ext4: only use fscrypt_zeroout_range() on regular files

Message ID 20191226161022.53490-1-ebiggers@kernel.org (mailing list archive)
State Accepted
Headers show
Series ext4: only use fscrypt_zeroout_range() on regular files | expand

Commit Message

Eric Biggers Dec. 26, 2019, 4:10 p.m. UTC
From: Eric Biggers <ebiggers@google.com>

fscrypt_zeroout_range() is only for encrypted regular files, not for
encrypted directories or symlinks.

Fortunately, currently it seems it's never called on non-regular files.
But to be safe ext4 should explicitly check S_ISREG() before calling it.

Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 fs/ext4/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Theodore Ts'o Jan. 13, 2020, 7:34 p.m. UTC | #1
On Thu, Dec 26, 2019 at 10:10:22AM -0600, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> fscrypt_zeroout_range() is only for encrypted regular files, not for
> encrypted directories or symlinks.
> 
> Fortunately, currently it seems it's never called on non-regular files.
> But to be safe ext4 should explicitly check S_ISREG() before calling it.
> 
> Signed-off-by: Eric Biggers <ebiggers@google.com>

Thanks, applied.

					- Ted
diff mbox series

Patch

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index b8f8afd2e8b2..6586b29e9f2f 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -402,7 +402,7 @@  int ext4_issue_zeroout(struct inode *inode, ext4_lblk_t lblk, ext4_fsblk_t pblk,
 {
 	int ret;
 
-	if (IS_ENCRYPTED(inode))
+	if (IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode))
 		return fscrypt_zeroout_range(inode, lblk, pblk, len);
 
 	ret = sb_issue_zeroout(inode->i_sb, pblk, len, GFP_NOFS);