diff options
| author | Jan Kara <jack@suse.cz> | 2025-07-11 19:01:20 +0200 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-08-28 16:25:51 +0200 |
| commit | fc5d14e5bd3740f6e35594440f89a7f50aabba26 (patch) | |
| tree | d088dbcf18763fdc8713cd9681f85a719fdf3aff /fs/udf | |
| parent | ac98d54630d5b52e3f684d872f0d82c06c418ea9 (diff) | |
| download | linux-fc5d14e5bd3740f6e35594440f89a7f50aabba26.tar.gz linux-fc5d14e5bd3740f6e35594440f89a7f50aabba26.tar.bz2 linux-fc5d14e5bd3740f6e35594440f89a7f50aabba26.zip | |
udf: Verify partition map count
[ Upstream commit 1a11201668e8635602577dcf06f2e96c591d8819 ]
Verify that number of partition maps isn't insanely high which can lead
to large allocation in udf_sb_alloc_partition_maps(). All partition maps
have to fit in the LVD which is in a single block.
Reported-by: syzbot+478f2c1a6f0f447a46bb@syzkaller.appspotmail.com
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/udf')
| -rw-r--r-- | fs/udf/super.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/fs/udf/super.c b/fs/udf/super.c index fa790be4f19f..a186d2418b50 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -1410,7 +1410,7 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block, struct genericPartitionMap *gpm; uint16_t ident; struct buffer_head *bh; - unsigned int table_len; + unsigned int table_len, part_map_count; int ret; bh = udf_read_tagged(sb, block, block, &ident); @@ -1431,7 +1431,16 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block, "logical volume"); if (ret) goto out_bh; - ret = udf_sb_alloc_partition_maps(sb, le32_to_cpu(lvd->numPartitionMaps)); + + part_map_count = le32_to_cpu(lvd->numPartitionMaps); + if (part_map_count > table_len / sizeof(struct genericPartitionMap1)) { + udf_err(sb, "error loading logical volume descriptor: " + "Too many partition maps (%u > %u)\n", part_map_count, + table_len / (unsigned)sizeof(struct genericPartitionMap1)); + ret = -EIO; + goto out_bh; + } + ret = udf_sb_alloc_partition_maps(sb, part_map_count); if (ret) goto out_bh; |
