Commit e586e22
iommu: Protect against overflow in iommu_pgsize()
On a 32 bit system calling:
iommu_map(0, 0x40000000)
When using the AMD V1 page table type with a domain->pgsize of 0xfffff000
causes iommu_pgsize() to miscalculate a result of:
size=0x40000000 count=2
count should be 1. This completely corrupts the mapping process.
This is because the final test to adjust the pagesize malfunctions when
the addition overflows. Use check_add_overflow() to prevent this.
Fixes: b1d99dc ("iommu: Hook up '->unmap_pages' driver callback")
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/r/0-v1-3ad28fc2e3a3+163327-iommu_overflow_pgsize_jgg@nvidia.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>1 parent da33e87 commit e586e22
1 file changed
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2413 | 2413 | | |
2414 | 2414 | | |
2415 | 2415 | | |
| 2416 | + | |
2416 | 2417 | | |
2417 | 2418 | | |
2418 | 2419 | | |
| |||
2453 | 2454 | | |
2454 | 2455 | | |
2455 | 2456 | | |
2456 | | - | |
| 2457 | + | |
| 2458 | + | |
2457 | 2459 | | |
2458 | 2460 | | |
2459 | 2461 | | |
| |||
0 commit comments