summaryrefslogtreecommitdiffstats
path: root/include/asm-s390/mmu.h
diff options
context:
space:
mode:
authorEric Sandeen2008-01-29 05:58:27 +0100
committerTheodore Ts'o2008-01-29 05:58:27 +0100
commite7c95593001cb96ef5dd121a4523286c574c7133 (patch)
treee49d172341611a20e9e5394379801d4e97977a0b /include/asm-s390/mmu.h
parentext4/super.c: fix #ifdef's (CONFIG_EXT4_* -> CONFIG_EXT4DEV_*) (diff)
downloadkernel-qcow2-linux-e7c95593001cb96ef5dd121a4523286c574c7133.tar.gz
kernel-qcow2-linux-e7c95593001cb96ef5dd121a4523286c574c7133.tar.xz
kernel-qcow2-linux-e7c95593001cb96ef5dd121a4523286c574c7133.zip
ext4: fix oops on corrupted ext4 mount
When mounting an ext4 filesystem with corrupted s_first_data_block, things can go very wrong and oops. Because blocks_count in ext4_fill_super is a u64, and we must use do_div, the calculation of db_count is done differently than on ext4. If first_data_block is corrupted such that it is larger than ext4_blocks_count, for example, then the intermediate blocks_count value may go negative, but sign-extend to a very large value: blocks_count = (ext4_blocks_count(es) - le32_to_cpu(es->s_first_data_block) + EXT4_BLOCKS_PER_GROUP(sb) - 1); This is then assigned to s_groups_count which is an unsigned long: sbi->s_groups_count = blocks_count; This may result in a value of 0xFFFFFFFF which is then used to compute db_count: db_count = (sbi->s_groups_count + EXT4_DESC_PER_BLOCK(sb) - 1) / EXT4_DESC_PER_BLOCK(sb); and in this case db_count will wind up as 0 because the addition overflows 32 bits. This in turn causes the kmalloc for group_desc to be of 0 size: sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *), GFP_KERNEL); and eventually in ext4_check_descriptors, dereferencing sbi->s_group_desc[desc_block] will result in a NULL pointer dereference. The simplest test seems to be to sanity check s_first_data_block, EXT4_BLOCKS_PER_GROUP, and ext4_blocks_count values to be sure their combination won't result in a bad intermediate value for blocks_count. We could just check for db_count == 0, but catching it at the root cause seems like it provides more info. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Mingming Cao <cmm@us.ibm.com>
Diffstat (limited to 'include/asm-s390/mmu.h')
0 files changed, 0 insertions, 0 deletions