Skip to content

Commit 08841b0

Browse files
msh1307jankara
authored andcommitted
udf: fix partition descriptor append bookkeeping
Mounting a crafted UDF image with repeated partition descriptors can trigger a heap out-of-bounds write in part_descs_loc[]. handle_partition_descriptor() deduplicates entries by partition number, but appended slots never record partnum. As a result duplicate Partition Descriptors are appended repeatedly and num_part_descs keeps growing. Once the table is full, the growth path still sizes the allocation from partnum even though inserts are indexed by num_part_descs. If partnum is already aligned to PART_DESC_ALLOC_STEP, ALIGN(partnum, step) can keep the old capacity and the next append writes past the end of the table. Store partnum in the appended slot and size growth from the next append count so deduplication and capacity tracking follow the same model. Fixes: ee4af50 ("udf: Fix mounting of Win7 created UDF filesystems") Cc: stable@vger.kernel.org Signed-off-by: Seohyeon Maeng <bioloidgp@gmail.com> Link: https://patch.msgid.link/20260310081652.21220-1-bioloidgp@gmail.com Signed-off-by: Jan Kara <jack@suse.cz>
1 parent 19134a1 commit 08841b0

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

fs/udf/super.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1694,8 +1694,9 @@ static struct udf_vds_record *handle_partition_descriptor(
16941694
return &(data->part_descs_loc[i].rec);
16951695
if (data->num_part_descs >= data->size_part_descs) {
16961696
struct part_desc_seq_scan_data *new_loc;
1697-
unsigned int new_size = ALIGN(partnum, PART_DESC_ALLOC_STEP);
1697+
unsigned int new_size;
16981698

1699+
new_size = data->num_part_descs + PART_DESC_ALLOC_STEP;
16991700
new_loc = kzalloc_objs(*new_loc, new_size);
17001701
if (!new_loc)
17011702
return ERR_PTR(-ENOMEM);
@@ -1705,6 +1706,7 @@ static struct udf_vds_record *handle_partition_descriptor(
17051706
data->part_descs_loc = new_loc;
17061707
data->size_part_descs = new_size;
17071708
}
1709+
data->part_descs_loc[data->num_part_descs].partnum = partnum;
17081710
return &(data->part_descs_loc[data->num_part_descs++].rec);
17091711
}
17101712

0 commit comments

Comments
 (0)