Skip to contentSkip to conversation

drm/nouveau/mmu: fix potential overflow in PFN size calculation

PATCH New Alexey Nepomnyashih 1 participant 1 message May 23, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/nouveau/mmu: fix potential overflow in PFN size calculation

On most Linux-supported platforms, int is 32-bit, making (1 << 47) undefined and potentially dangerous. To ensure defined behavior and correct 64-bit arithmetic, replace 1 with 1ULL.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes a5ff307fe1f2 ("drm/nouveau/mmu: add a privileged method to directly manage PTEs")
---
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c +1 -1
index 9c97800fe037..29da1acbe3a8 100644
@@ -1383,7 +1383,7 @@ nvkm_vmm_pfn_map(struct nvkm_vmm *vmm, u8 shift, u64 addr, u64 size, u64 *pfn)
 			 */
 			while (size) {
 				pfn[pi++] = NVKM_VMM_PFN_NONE;
-				size -= 1 << page->shift;
+				size -= 1ULL << page->shift;
 			}
 		} else {
 			pi += size >> page->shift;
Signature · 1 line
2.43.0