iommupt: Return ERR_PTR from _table_alloc()
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.
--- drivers/iommu/generic_pt/iommu_pt.h | 3 +++ 1 file changed, 3 insertions(+)
drivers/iommu/generic_pt/iommu_pt.h +3 -0
@@ -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
Quoted 6 lines · Jason Gunthorpe
syzkaller noticed that with fault injection a failure inside
iommu_alloc_pages_node_sz()oops's inPT_FEAT_DMA_INCOHERENTbecause it goes on to make NULL incoherent. Closer inspection shows the return value has become confused, the alloc routines on the iommupt side expectERR_PTRwhileiommu_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]Signed-off-by Jason Gunthorpe<[email protected]>
Quoted 15 lines
From: Jason Gunthorpe <[email protected]>
Sent: Thursday, December 18, 2025 1:43 AMsyzkaller noticed that with fault injection a failure inside
iommu_alloc_pages_node_sz()oops's inPT_FEAT_DMA_INCOHERENTbecause it goes
on to make NULL incoherent. Closer inspection shows the return value has become confused, the alloc routines on the iommupt side expectERR_PTRwhileiommu_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 iommuimplementation")
Reported-by [email protected]Closes:
https://lore.kernel.org/all/[email protected]
m/Signed-off-by Jason Gunthorpe <[email protected]>
Quoted 14 lines · Jason Gunthorpe
syzkaller noticed that with fault injection a failure inside
iommu_alloc_pages_node_sz()oops's inPT_FEAT_DMA_INCOHERENTbecause it goes on to make NULL incoherent. Closer inspection shows the return value has become confused, the alloc routines on the iommupt side expectERR_PTRwhileiommu_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]Signed-off-by Jason Gunthorpe <[email protected]>
Quoted 3 lines
--- drivers/iommu/generic_pt/iommu_pt.h | 3 +++ 1 file changed, 3 insertions(+)
Applied, thanks.