Skip to contentSkip to conversation

iommupt: Return ERR_PTR from _table_alloc()

PATCH Applied Jason Gunthorpe 4 participants 4 messages Dec 17, 2025 – Dec 18, 2025 IOMMU

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommupt: Return ERR_PTR from _table_alloc()

syzkaller noticed that with fault injection a failure inside iommu_alloc_pages_node_sz() oops's in PT_FEAT_DMA_INCOHERENT because it goes on to make NULL incoherent. Closer inspection shows the return value has become confused, the alloc routines on the iommupt side expect ERR_PTR while iommu_alloc_pages_node_sz() returns NULL.

Error out early to fix both issues.

Fixes aefd967dab64 ("iommupt: Use the incoherent start/stop functions for PT_FEAT_DMA_INCOHERENT")
Fixes dcd6a011a8d5 ("iommupt: Add map_pages op")
Fixes cdb39d918579 ("iommupt: Add the basic structure of the iommu implementation")
Reported-by [email protected]
---
 drivers/iommu/generic_pt/iommu_pt.h | 3 +++
 1 file changed, 3 insertions(+)
drivers/iommu/generic_pt/iommu_pt.h +3 -0
index 97aeda1ad01cca..3327116a441cac 100644
@@ -372,6 +372,9 @@ static inline struct pt_table_p *_table_alloc(struct pt_common *common,
 
 	table_mem = iommu_alloc_pages_node_sz(iommu_table->nid, gfp,
 					      log2_to_int(lg2sz));
+	if (!table_mem)
+		return ERR_PTR(-ENOMEM);
+
 	if (pt_feature(common, PT_FEAT_DMA_INCOHERENT) &&
 	    mode == ALLOC_NORMAL) {
 		int ret = iommu_pages_start_incoherent(

base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8

Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Jason Gunthorpe

syzkaller noticed that with fault injection a failure inside iommu_alloc_pages_node_sz() oops's in PT_FEAT_DMA_INCOHERENT because it goes on to make NULL incoherent. Closer inspection shows the return value has become confused, the alloc routines on the iommupt side expect ERR_PTR while iommu_alloc_pages_node_sz() returns NULL.

Quoted 8 lines

Error out early to fix both issues.

Fixes aefd967dab64 ("iommupt: Use the incoherent start/stop functions for PT_FEAT_DMA_INCOHERENT")
Fixes dcd6a011a8d5 ("iommupt: Add map_pages op")
Fixes cdb39d918579 ("iommupt: Add the basic structure of the iommu implementation")
Reported-by [email protected]
Reviewed-by on v1 1/1
#2 lore raw
In reply to Jason Gunthorpe
Quoted 15 lines

From: Jason Gunthorpe <[email protected]>
Sent: Thursday, December 18, 2025 1:43 AM

syzkaller noticed that with fault injection a failure inside iommu_alloc_pages_node_sz() oops's in PT_FEAT_DMA_INCOHERENT because it goes
on to make NULL incoherent. Closer inspection shows the return value has become confused, the alloc routines on the iommupt side expect ERR_PTR while
iommu_alloc_pages_node_sz() returns NULL.

Error out early to fix both issues.

Fixes aefd967dab64 ("iommupt: Use the incoherent start/stop functions for

PT_FEAT_DMA_INCOHERENT")

Quoted 8 lines
Fixes dcd6a011a8d5 ("iommupt: Add map_pages op")
Fixes cdb39d918579 ("iommupt: Add the basic structure of the iommu

implementation")

Reported-by [email protected]

Closes:
https://lore.kernel.org/all/[email protected]
m/

maintainer Applied
#3 lore raw
In reply to Jason Gunthorpe
Quoted 14 lines · Jason Gunthorpe

syzkaller noticed that with fault injection a failure inside iommu_alloc_pages_node_sz() oops's in PT_FEAT_DMA_INCOHERENT because it goes on to make NULL incoherent. Closer inspection shows the return value has become confused, the alloc routines on the iommupt side expect ERR_PTR while iommu_alloc_pages_node_sz() returns NULL.

Error out early to fix both issues.

Fixes aefd967dab64 ("iommupt: Use the incoherent start/stop functions for PT_FEAT_DMA_INCOHERENT")
Fixes dcd6a011a8d5 ("iommupt: Add map_pages op")
Fixes cdb39d918579 ("iommupt: Add the basic structure of the iommu implementation")
Reported-by [email protected]
Quoted 3 lines
---
 drivers/iommu/generic_pt/iommu_pt.h | 3 +++
 1 file changed, 3 insertions(+)

Applied, thanks.