From: Dheeraj Kumar Srivastava <dheerajkumar.srivastava@amd.com>
To: <joro@8bytes.org>, <suravee.suthikulpanit@amd.com>,
<will@kernel.org>, <robin.murphy@arm.com>,
<iommu@lists.linux.dev>, <linux-kernel@vger.kernel.org>
Cc: <Vasant.Hegde@amd.com>,
Dheeraj Kumar Srivastava <dheerajkumar.srivastava@amd.com>,
Sairaj Kodilkar <Sairaj.ArunKodilkar@amd.com>,
kernel test robot <lkp@intel.com>,
"Dan Carpenter" <error27@gmail.com>
Subject: [PATCH] iommu/amd: Use array_index_nospec() for rlookup_table index
Date: Fri, 9 Jan 2026 10:50:40 +0530 [thread overview]
Message-ID: <20260109052040.938-1-dheerajkumar.srivastava@amd.com> (raw)
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
next reply other threads:[~2026-01-09 5:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-09 5:20 Dheeraj Kumar Srivastava [this message]
2026-01-09 6:05 ` [PATCH] iommu/amd: Use array_index_nospec() for rlookup_table index Dan Carpenter
2026-01-09 8:49 ` Dheeraj Kumar Srivastava
2026-01-09 9:27 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260109052040.938-1-dheerajkumar.srivastava@amd.com \
--to=dheerajkumar.srivastava@amd.com \
--cc=Sairaj.ArunKodilkar@amd.com \
--cc=Vasant.Hegde@amd.com \
--cc=error27@gmail.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=robin.murphy@arm.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox