Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: ee4af50ca94f ("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>

authored by

Seohyeon Maeng and committed by
Jan Kara
08841b06 19134a13

+3 -1
+3 -1
fs/udf/super.c
··· 1694 1694 return &(data->part_descs_loc[i].rec); 1695 1695 if (data->num_part_descs >= data->size_part_descs) { 1696 1696 struct part_desc_seq_scan_data *new_loc; 1697 - unsigned int new_size = ALIGN(partnum, PART_DESC_ALLOC_STEP); 1697 + unsigned int new_size; 1698 1698 1699 + new_size = data->num_part_descs + PART_DESC_ALLOC_STEP; 1699 1700 new_loc = kzalloc_objs(*new_loc, new_size); 1700 1701 if (!new_loc) 1701 1702 return ERR_PTR(-ENOMEM); ··· 1706 1705 data->part_descs_loc = new_loc; 1707 1706 data->size_part_descs = new_size; 1708 1707 } 1708 + data->part_descs_loc[data->num_part_descs].partnum = partnum; 1709 1709 return &(data->part_descs_loc[data->num_part_descs++].rec); 1710 1710 } 1711 1711