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 <[email protected]>
Reviewed-by: Lu Baolu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Joerg Roedel <[email protected]>1 parent da33e87 commit e586e22
1 file changed
+3
-1
lines changed| 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