mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-08-09 06:14:34 +02:00
udf: fix partition descriptor append bookkeeping
[ Upstream commit08841b06fa] 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:ee4af50ca9("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> [ replaced kzalloc_objs() helper with equivalent kcalloc() ] Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
ed2d6442e6
commit
e8474cfbac
+3
-1
@@ -1657,8 +1657,9 @@ static struct udf_vds_record *handle_partition_descriptor(
|
||||
return &(data->part_descs_loc[i].rec);
|
||||
if (data->num_part_descs >= data->size_part_descs) {
|
||||
struct part_desc_seq_scan_data *new_loc;
|
||||
unsigned int new_size = ALIGN(partnum, PART_DESC_ALLOC_STEP);
|
||||
unsigned int new_size;
|
||||
|
||||
new_size = data->num_part_descs + PART_DESC_ALLOC_STEP;
|
||||
new_loc = kcalloc(new_size, sizeof(*new_loc), GFP_KERNEL);
|
||||
if (!new_loc)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
@@ -1668,6 +1669,7 @@ static struct udf_vds_record *handle_partition_descriptor(
|
||||
data->part_descs_loc = new_loc;
|
||||
data->size_part_descs = new_size;
|
||||
}
|
||||
data->part_descs_loc[data->num_part_descs].partnum = partnum;
|
||||
return &(data->part_descs_loc[data->num_part_descs++].rec);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user