Skip to contentSkip to conversation

ext4: only use fscrypt_zeroout_range() on regular files

PATCH Applied Eric Biggers 2 participants 2 messages Dec 26, 2019 – Jan 13, 2020

Subsystems (2)
lore
Share & tools
lore

Eric Biggers

author maintainer
#0 lore raw

PATCH 1/1 ext4: only use fscrypt_zeroout_range() on regular files

From: Eric Biggers <[email protected]>

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.

---
 fs/ext4/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/inode.c +1 -1
index b8f8afd2e8b2..6586b29e9f2f 100644
@@ -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);
Signature · 1 line
2.24.1
maintainer Applied
#1 lore raw
Quoted 9 lines · Eric Biggers

From: Eric Biggers <[email protected]>

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.

Thanks, applied.

- Ted