ANDROID: ext4 crypto: Disables zeroing on truncation when there's no key

When performing orphan cleanup on mount, ext4 may truncate pages.
Truncation as currently implemented may require the encryption key for
partial zeroing, and the key isn't necessarily available on mount.
Since the userspace tools don't perform the partial zeroing operation
anyway, let's just skip doing that in the kernel.

This patch fixes a BUG_ON() oops.

Bug: 35209576
Change-Id: I2527a3f8d2c57d2de5df03fda69ee397f76095d7
Signed-off-by: Michael Halcrow <mhalcrow@google.com>
This commit is contained in:
Michael Halcrow 2017-02-13 09:22:36 -08:00 committed by Amit Pundir
parent fdd80e55d3
commit f93b9ef1d6

View File

@ -4062,6 +4062,11 @@ static int ext4_block_truncate_page(handle_t *handle,
if (ext4_encrypted_inode(inode) && !fscrypt_has_encryption_key(inode))
return 0;
/* If we are processing an encrypted inode during orphan list
* handling */
if (ext4_encrypted_inode(inode) && !fscrypt_has_encryption_key(inode))
return 0;
blocksize = inode->i_sb->s_blocksize;
length = blocksize - (offset & (blocksize - 1));