Skip to contentSkip to conversation

ext4: handle decryption error in __ext4_block_zero_page_range()

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: handle decryption error in __ext4_block_zero_page_range()

From: Eric Biggers <[email protected]>

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.

---
 fs/ext4/inode.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
fs/ext4/inode.c +6 -2
index 629a25d999f0..b8f8afd2e8b2 100644
@@ -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)) {
Signature · 1 line
2.24.1
maintainer Applied
#1 lore raw
Quoted 7 lines · Eric Biggers

From: Eric Biggers <[email protected]>

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.

Quoted 6 lines

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.

Thanks, applied.

- Ted