Skip to content

Commit adb8164

Browse files
committed
iommu/s390: Fix memory corruption when using identity domain
JIRA: https://issues.redhat.com/browse/RHEL-113440 commit b3506e9 Author: Matthew Rosato <mjrosato@linux.ibm.com> Date: Wed Aug 27 17:08:27 2025 -0400 iommu/s390: Fix memory corruption when using identity domain zpci_get_iommu_ctrs() returns counter information to be reported as part of device statistics; these counters are stored as part of the s390_domain. The problem, however, is that the identity domain is not backed by an s390_domain and so the conversion via to_s390_domain() yields a bad address that is zero'd initially and read on-demand later via a sysfs read. These counters aren't necessary for the identity domain; just return NULL in this case. This issue was discovered via KASAN with reports that look like: BUG: KASAN: global-out-of-bounds in zpci_fmb_enable_device when using the identity domain for a device on s390. Cc: stable@vger.kernel.org Fixes: 64af12c ("iommu/s390: implement iommu passthrough via identity domain") Reported-by: Cam Miller <cam@linux.ibm.com> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com> Tested-by: Cam Miller <cam@linux.ibm.com> Reviewed-by: Farhan Ali <alifm@linux.ibm.com> Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com> Link: https://lore.kernel.org/r/20250827210828.274527-1-mjrosato@linux.ibm.com Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
1 parent 891ce08 commit adb8164

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/iommu/s390-iommu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,8 @@ struct zpci_iommu_ctrs *zpci_get_iommu_ctrs(struct zpci_dev *zdev)
10311031

10321032
lockdep_assert_held(&zdev->dom_lock);
10331033

1034-
if (zdev->s390_domain->type == IOMMU_DOMAIN_BLOCKED)
1034+
if (zdev->s390_domain->type == IOMMU_DOMAIN_BLOCKED ||
1035+
zdev->s390_domain->type == IOMMU_DOMAIN_IDENTITY)
10351036
return NULL;
10361037

10371038
s390_domain = to_s390_domain(zdev->s390_domain);

0 commit comments

Comments
 (0)