mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iommufd: Fix NULL deref of area->pages in ioas_change_process
@ 2026-08-18  3:36 Deepanshu Kartikey
  2026-08-18  6:07 ` Tushar Nimkar
  0 siblings, 1 reply; 2+ messages in thread
From: Deepanshu Kartikey @ 2026-08-18  3:36 UTC (permalink / raw)
  To: jgg, kevin.tian, joro, will, robin.murphy
  Cc: steven.sistare, iommu, linux-kernel, Deepanshu Kartikey,
	syzbot+48637757323884de77a2

Areas are inserted into the area_itree before area->pages is assigned,
so an area with a NULL pages pointer is briefly visible to readers.
iommufd_ioas_change_process() walks every area and dereferences
area->pages unconditionally, which oopses when racing with a
concurrent IOMMU_IOAS_MAP_FILE.

Reject the racing case with -EBUSY, matching how
iopt_unmap_iova_range() handles the same window. Checking in the first
loop covers the whole function since all iova_rwsems are held for
write across the call.

Fixes: 829ed626499c ("iommufd: Add IOMMU_IOAS_CHANGE_PROCESS")
Reported-by: syzbot+48637757323884de77a2@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=48637757323884de77a2
Tested-by: syzbot+48637757323884de77a2@syzkaller.appspotmail.com
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
 drivers/iommu/iommufd/ioas.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/iommu/iommufd/ioas.c b/drivers/iommu/iommufd/ioas.c
index fed06c2b728e..71bffece84b5 100644
--- a/drivers/iommu/iommufd/ioas.c
+++ b/drivers/iommu/iommufd/ioas.c
@@ -535,6 +535,10 @@ int iommufd_ioas_change_process(struct iommufd_ucmd *ucmd)
 		return rc;
 
 	for_each_ioas_area(&ioas_list, index, ioas, area)  {
+		if (!area->pages) {
+			rc = -EBUSY;
+			goto out;
+		}
 		if (area->pages->type != IOPT_ADDRESS_FILE) {
 			rc = -EINVAL;
 			goto out;
-- 
2.34.1


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

end of thread, other threads:[~2026-08-18  6:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-18  3:36 [PATCH] iommufd: Fix NULL deref of area->pages in ioas_change_process Deepanshu Kartikey
2026-08-18  6:07 ` Tushar Nimkar

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

all inboxes | Powered by JetHome®