]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
iommu/amd: Fix potential out-of-bounds read in iommu_mmio_show
authorSongtang Liu <liusongtang@bytedance.com>
Fri, 31 Oct 2025 05:55:25 +0000 (22:55 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Dec 2025 13:02:49 +0000 (14:02 +0100)
commit0ec4aaf5f3f559716a6559f3d6d9616e9470bed6
tree2ecc64d40dc1e1cebc4c1223e44b7165a15ca00a
parente31c902d785411eb4a246fba2e8a32aa59d33ce2
iommu/amd: Fix potential out-of-bounds read in iommu_mmio_show

[ Upstream commit a0c7005333f9a968abb058b1d77bbcd7fb7fd1e7 ]

In iommu_mmio_write(), it validates the user-provided offset with the
check: `iommu->dbg_mmio_offset > iommu->mmio_phys_end - 4`.
This assumes a 4-byte access. However, the corresponding
show handler, iommu_mmio_show(), uses readq() to perform an 8-byte
(64-bit) read.

If a user provides an offset equal to `mmio_phys_end - 4`, the check
passes, and will lead to a 4-byte out-of-bounds read.

Fix this by adjusting the boundary check to use sizeof(u64), which
corresponds to the size of the readq() operation.

Fixes: 7a4ee419e8c1 ("iommu/amd: Add debugfs support to dump IOMMU MMIO registers")
Signed-off-by: Songtang Liu <liusongtang@bytedance.com>
Reviewed-by: Dheeraj Kumar Srivastava <dheerajkumar.srivastava@amd.com>
Tested-by: Dheeraj Kumar Srivastava <dheerajkumar.srivastava@amd.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iommu/amd/debugfs.c