Linux-FSCrypt Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] ext4: only use fscrypt_zeroout_range() on regular files
@ 2019-12-26 16:10 Eric Biggers
  2020-01-13 19:34 ` Theodore Y. Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Biggers @ 2019-12-26 16:10 UTC (permalink / raw)
  To: linux-ext4; +Cc: linux-fscrypt

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(-)

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);
-- 
2.24.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ext4: only use fscrypt_zeroout_range() on regular files
  2019-12-26 16:10 [PATCH] ext4: only use fscrypt_zeroout_range() on regular files Eric Biggers
@ 2020-01-13 19:34 ` Theodore Y. Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Y. Ts'o @ 2020-01-13 19:34 UTC (permalink / raw)
  To: Eric Biggers; +Cc: linux-ext4, linux-fscrypt

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-26 16:10 [PATCH] ext4: only use fscrypt_zeroout_range() on regular files Eric Biggers
2020-01-13 19:34 ` Theodore Y. Ts'o

Linux-FSCrypt Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-fscrypt/0 linux-fscrypt/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-fscrypt linux-fscrypt/ https://lore.kernel.org/linux-fscrypt \
		linux-fscrypt@vger.kernel.org
	public-inbox-index linux-fscrypt

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-fscrypt


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git