Linux-ext4 Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] ext4: handle decryption error in __ext4_block_zero_page_range()
@ 2019-12-26 15:41 Eric Biggers
  2020-01-13 19:25 ` Theodore Y. Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Biggers @ 2019-12-26 15:41 UTC (permalink / raw)
  To: linux-ext4; +Cc: linux-fscrypt

From: Eric Biggers <ebiggers@google.com>

fscrypt_decrypt_pagecache_blocks() can fail, because it uses
skcipher_request_alloc(), which uses kmalloc(), which can fail; and also
because it calls crypto_skcipher_decrypt(), which can fail depending on
the driver that actually implements the crypto.

Therefore it's not appropriate to WARN on decryption error in
__ext4_block_zero_page_range().

Remove the WARN and just handle the error instead.

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

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 629a25d999f0..b8f8afd2e8b2 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3701,8 +3701,12 @@ static int __ext4_block_zero_page_range(handle_t *handle,
 		if (S_ISREG(inode->i_mode) && IS_ENCRYPTED(inode)) {
 			/* We expect the key to be set. */
 			BUG_ON(!fscrypt_has_encryption_key(inode));
-			WARN_ON_ONCE(fscrypt_decrypt_pagecache_blocks(
-					page, blocksize, bh_offset(bh)));
+			err = fscrypt_decrypt_pagecache_blocks(page, blocksize,
+							       bh_offset(bh));
+			if (err) {
+				clear_buffer_uptodate(bh);
+				goto unlock;
+			}
 		}
 	}
 	if (ext4_should_journal_data(inode)) {
-- 
2.24.1


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

* Re: [PATCH] ext4: handle decryption error in __ext4_block_zero_page_range()
  2019-12-26 15:41 [PATCH] ext4: handle decryption error in __ext4_block_zero_page_range() Eric Biggers
@ 2020-01-13 19:25 ` Theodore Y. Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Y. Ts'o @ 2020-01-13 19:25 UTC (permalink / raw)
  To: Eric Biggers; +Cc: linux-ext4, linux-fscrypt

On Thu, Dec 26, 2019 at 09:41:05AM -0600, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> fscrypt_decrypt_pagecache_blocks() can fail, because it uses
> skcipher_request_alloc(), which uses kmalloc(), which can fail; and also
> because it calls crypto_skcipher_decrypt(), which can fail depending on
> the driver that actually implements the crypto.
> 
> Therefore it's not appropriate to WARN on decryption error in
> __ext4_block_zero_page_range().
> 
> Remove the WARN and just handle the error instead.
> 
> 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 15:41 [PATCH] ext4: handle decryption error in __ext4_block_zero_page_range() Eric Biggers
2020-01-13 19:25 ` Theodore Y. Ts'o

Linux-ext4 Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-ext4/0 linux-ext4/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-ext4 linux-ext4/ https://lore.kernel.org/linux-ext4 \
		linux-ext4@vger.kernel.org
	public-inbox-index linux-ext4

Example config snippet for mirrors

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


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