]> git.ipfire.org Git - thirdparty/linux.git/commit
iommu/amd: Fix illegal device-id access in IOMMU debugfs
authorGuanghui Feng <guanghuifeng@linux.alibaba.com>
Thu, 19 Mar 2026 07:37:53 +0000 (15:37 +0800)
committerJoerg Roedel <joerg.roedel@amd.com>
Fri, 27 Mar 2026 08:26:58 +0000 (09:26 +0100)
commite4172c5b53fba04fa48b13bc3afde809d0087a7f
tree50238af2ca70ef7f55d995b22128ea5240e841d6
parent1e0c8d6b695217cb0b16f13e31c7f08b453097b4
iommu/amd: Fix illegal device-id access in IOMMU debugfs

In the current AMD IOMMU debugFS, when multiple processes use the IOMMU
debugFS process simultaneously, illegal access issues can occur in the
following execution flow:

1. CPU1: Sets a valid sbdf via devid_write, then checks the sbdf's
validity in execution flows such as devid_show, iommu_devtbl_show,
and iommu_irqtbl_show.

2. CPU2: Sets an invalid sbdf via devid_write, at which point the sbdf
value is -1.

3. CPU1: accesses the IOMMU device table, IRQ table, based on the
invalid SBDF value of -1, resulting in illegal access.

This is especially problematic in monitoring scripts, where multiple
scripts may access debugFS simultaneously, and some scripts may
unexpectedly set invalid values, which triggers illegal access in
debugfs.

This patch modifies the execution flow of devid_show,
iommu_devtbl_show, and iommu_irqtbl_show to ensure that these
processes determine the validity and access based on the
same device-id, thus guaranteeing correctness and robustness.

Signed-off-by: Guanghui Feng <guanghuifeng@linux.alibaba.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
drivers/iommu/amd/debugfs.c