From cabde4999d1d10b6ace32eaddc99699b91e40551 Mon Sep 17 00:00:00 2001 From: Lukas Czerner Date: Thu, 28 Jun 2018 15:59:09 +0200 Subject: e2fsck: do not allow initialized blocks pass i_size We do not allow initialized blocks to exist past i_size as this could lead to stale data exposure. Remove test f_pgsize_gt_blksize because it is testing for the scenario that not allowed. f_eofblocks is already testing for this. Signed-off-by: Lukas Czerner Signed-off-by: Theodore Ts'o --- e2fsck/pass1.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'e2fsck/pass1.c') diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index f1fa5d94..461f5fb6 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -3448,16 +3448,8 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, size = EXT2_I_SIZE(inode); if ((pb.last_init_lblock >= 0) && - /* if size is smaller than expected by the block count, - * allow allocated blocks to end of PAGE_SIZE. - * last_init_lblock is the last in-use block, so it is - * the minimum expected file size, but +1 because it is - * the base-zero block number and not the block count. */ - (size < (__u64)pb.last_init_lblock * fs->blocksize) && - ((pb.last_init_lblock + 1) / blkpg * blkpg != - (pb.last_init_lblock + 1) || - size < (__u64)(pb.last_init_lblock & ~(blkpg - 1)) * - fs->blocksize)) + /* Do not allow initialized allocated blocks past i_size*/ + (size < (__u64)pb.last_init_lblock * fs->blocksize)) bad_size = 3; else if (!(extent_fs && (inode->i_flags & EXT4_EXTENTS_FL)) && size > ext2_max_sizes[fs->super->s_log_block_size]) -- cgit v1.2.3