Skip to content

Commit bb0d384

Browse files
bryamzxzgregkh
authored andcommitted
udf: validate VAT header length against the VAT inode size
commit d820278 upstream. udf_load_vat() takes the virtual partition's start offset straight from the on-disk VAT 2.0 header without checking it against the VAT inode size: map->s_type_specific.s_virtual.s_start_offset = le16_to_cpu(vat20->lengthHeader); map->s_type_specific.s_virtual.s_num_entries = (sbi->s_vat_inode->i_size - map->s_type_specific.s_virtual.s_start_offset) >> 2; lengthHeader is a fully attacker-controlled 16-bit value. If it exceeds the VAT inode size, the s_num_entries subtraction underflows to a huge count, which defeats the "block > s_num_entries" bound in udf_get_pblock_virt15(); and on the ICB-inline path that function reads ((__le32 *)(iinfo->i_data + s_start_offset))[block] so a large s_start_offset indexes past the inode's in-ICB data. Mounting a crafted UDF image with a virtual (VAT) partition then triggers an out-of-bounds read. Reject a VAT whose header length does not leave room for at least one entry within the VAT inode. Fixes: fa5e081 ("udf: Handle VAT packed inside inode properly") Cc: stable@vger.kernel.org Signed-off-by: Bryam Vargas <hexlabsecurity@proton.me> Link: https://patch.msgid.link/20260612-b4-disp-9a2317ee-v1-1-fefef5736154@proton.me Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent fb49099 commit bb0d384

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

fs/udf/super.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,14 @@ static int udf_load_vat(struct super_block *sb, int p_index, int type1_index)
12321232

12331233
map->s_type_specific.s_virtual.s_start_offset =
12341234
le16_to_cpu(vat20->lengthHeader);
1235+
if (map->s_type_specific.s_virtual.s_start_offset
1236+
> sbi->s_vat_inode->i_size) {
1237+
udf_err(sb, "Corrupted VAT header length %u (VAT inode size %lld)\n",
1238+
map->s_type_specific.s_virtual.s_start_offset,
1239+
sbi->s_vat_inode->i_size);
1240+
brelse(bh);
1241+
return -EFSCORRUPTED;
1242+
}
12351243
map->s_type_specific.s_virtual.s_num_entries =
12361244
(sbi->s_vat_inode->i_size -
12371245
map->s_type_specific.s_virtual.

0 commit comments

Comments
 (0)