Linux IOMMU Development
 help / color / mirror / Atom feed
* [PATCH] iommu/amd: Use array_index_nospec() for rlookup_table index
@ 2026-01-09  5:20 Dheeraj Kumar Srivastava
  2026-01-09  6:05 ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: Dheeraj Kumar Srivastava @ 2026-01-09  5:20 UTC (permalink / raw)
  To: joro, suravee.suthikulpanit, will, robin.murphy, iommu,
	linux-kernel
  Cc: Vasant.Hegde, Dheeraj Kumar Srivastava, Sairaj Kodilkar,
	kernel test robot, Dan Carpenter

Use array_index_nospec() to prevent speculative out-of-bounds
access when indexing pci_seg->rlookup_table with a user provided
device id.

Signed-off-by: Dheeraj Kumar Srivastava <dheerajkumar.srivastava@amd.com>
Reviewed-by: Sairaj Kodilkar <Sairaj.ArunKodilkar@amd.com>
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Closes: https://lore.kernel.org/r/202510281233.q4cBnp3z-lkp@intel.com/
---
 drivers/iommu/amd/debugfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iommu/amd/debugfs.c b/drivers/iommu/amd/debugfs.c
index 10fa217a7119..4990f6db99ef 100644
--- a/drivers/iommu/amd/debugfs.c
+++ b/drivers/iommu/amd/debugfs.c
@@ -174,6 +174,7 @@ static ssize_t devid_write(struct file *filp, const char __user *ubuf,
 			kfree(srcid_ptr);
 			return -EINVAL;
 		}
+		devid = array_index_nospec(devid, (u32)pci_seg->last_bdf + 1);
 		iommu = pci_seg->rlookup_table[devid];
 		if (!iommu) {
 			kfree(srcid_ptr);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-01-09  9:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-09  5:20 [PATCH] iommu/amd: Use array_index_nospec() for rlookup_table index Dheeraj Kumar Srivastava
2026-01-09  6:05 ` Dan Carpenter
2026-01-09  8:49   ` Dheeraj Kumar Srivastava
2026-01-09  9:27     ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox