EncryptInPlace: ensure that backup superblocks get encrypted

Block groups with EXT4_BG_BLOCK_UNINIT still have backup superblocks
(and backup block group descriptors).  Fix EncryptInPlace to encrypt
these backup superblocks rather than leave them unencrypted.

Previously leaving the backup superblocks unencrypted didn't cause any
problems, but due to system/core commit 72abd7b246f7 ("Try to recover
corrupted ext4 /data with backup superblock") it is causing problems.

Bug: 162479411
Bug: 161871210
Change-Id: Ic090bf4e88193b289b04c5254ddf661ef40b037e
This commit is contained in:
Will Shiu 2020-07-29 17:03:17 +08:00 committed by Eric Biggers
parent 5de675c93b
commit 4ac43f0e16

View file

@ -205,9 +205,16 @@ static int encrypt_groups(struct encryptGroupsData* data) {
data->count = 0; data->count = 0;
for (block = 0; block < block_count; block++) { for (block = 0; block < block_count; block++) {
int used = (aux_info.bg_desc[i].bg_flags & EXT4_BG_BLOCK_UNINIT) int used;
? 0
: bitmap_get_bit(block_bitmap, block); if (aux_info.bg_desc[i].bg_flags & EXT4_BG_BLOCK_UNINIT) {
// In block groups with an uninitialized block bitmap, we only
// need to encrypt the backup superblock (if one is present).
used = (ext4_bg_has_super_block(i) && block < 1 + aux_info.bg_desc_blocks);
} else {
used = bitmap_get_bit(block_bitmap, block);
}
update_progress(data, used); update_progress(data, used);
if (used) { if (used) {
if (data->count == 0) { if (data->count == 0) {