CVE: CVE-2024-57999
Published: 2025-02-27
Description: In the Linux kernel, the following vulnerability has been resolved:

powerpc/pseries/iommu: IOMMU incorrectly marks MMIO range in DDW

Power Hypervisor can possibily allocate MMIO window intersecting with
Dynamic DMA Window (DDW) range, which is over 32-bit addressing.

These MMIO pages needs to be marked as reserved so that IOMMU doesn't map
DMA buffers in this range.

The current code is not marking these pages correctly which is resulting
in LPAR to OOPS while booting. The stack is at below

BUG: Unable to handle kernel data access on read at 0xc00800005cd40000
Faulting instruction address: 0xc[PII_REDACTED]5cdac
Oops: Kernel access of bad area, sig: 11 [#1]
LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries
Modules linked in: af_packet rfkill ibmveth(X) lpfc(+) nvmet_fc nvmet nvme_keyring crct10dif_vpmsum nvme_fc nvme_fabrics nvme_core be2net(+) nvme_auth rtc_generic nfsd auth_rpcgss nfs_acl lockd grace sunrpc fuse configfs ip_tables x_tables xfs libcrc32c dm_service_time ibmvfc(X) scsi_transport_fc vmx_crypto gf128mul crc32c_vpmsum dm_mirror dm_region_hash dm_log dm_multipath dm_mod sd_mod scsi_dh_emc scsi_dh_rdac scsi_dh_alua t10_pi crc64_rocksoft_generic crc64_rocksoft sg crc64 scsi_mod
Supported: Yes, External
CPU: 8 PID: 241 Comm: kworker/8:1 Kdump: loaded Not tainted 6.4.0-150600.23.14-default #1 SLE15-SP6 b44ee71c81261b9e4bab5e0cde1f2ed891d5359b
Hardware name: IBM,9080-M9S POWER9 (raw) 0x4e2103 0xf000005 of:IBM,FW950.B0 (VH950_149) hv:phyp pSeries
Workqueue: events work_for_cpu_fn
NIP:  c[PII_REDACTED]5cdac LR: c[PII_REDACTED]5e830 CTR: [PII_REDACTED]
REGS: c00001400c9ff770 TRAP: 0300   Not tainted  (6.4.0-150600.23.14-default)
MSR: [PII_REDACTED]80b033 <SF,VEC,VSX,EE,FP,ME,IR,DR,RI,LE>  CR: 24228448  XER: 00000001
CFAR: c[PII_REDACTED]5cdd4 DAR: c00800005cd40000 DSISR: 40000000 IRQMASK: 0
GPR00: c[PII_REDACTED]5e830 c00001400c9ffa10 c[PII_REDACTED]87d00 c00001400c4fe800
GPR04: [PII_REDACTED] [PII_REDACTED] [PII_REDACTED] [PII_REDACTED]
GPR08: [PII_REDACTED] [PII_REDACTED] c00800005cd40000 ffffffffffffffff
GPR12: [PII_REDACTED] c00000000a4c4f00 [PII_REDACTED] [PII_REDACTED]
GPR16: c00001400c4fe800 [PII_REDACTED] [PII_REDACTED] c[PII_REDACTED]8b800
GPR20: c00001401a7be980 c00001400eff3800 c000000002a2da68[PII_REDACTED]00002b
GPR24: c[PII_REDACTED]793a8 c[PII_REDACTED]79[PII_REDACTED]00000002a c[PII_REDACTED]793c8
GPR28: 000008007effffff [PII_REDACTED] [PII_REDACTED] c00001400c4fe800
NIP [c[PII_REDACTED]5cdac] iommu_table_reserve_pages+0xac/0x100
LR [c[PII_REDACTED]5e830] iommu_init_table+0x80/0x1e0
Call Trace:
[c00001400c9ffa10] [c[PII_REDACTED]5e810] iommu_init_table+0x60/0x1e0 (unreliable)
[c00001400c9ffa90] [c[PII_REDACTED]0356c] iommu_bypass_supported_pSeriesLP+0x9cc/0xe40
[c00001400c9ffc30] [c[PII_REDACTED]5c300] dma_iommu_dma_supported+0xf0/0x230
[c00001400c9ffcb0] [c[PII_REDACTED]4b0c4] dma_supported+0x44/0x90
[c00001400c9ffcd0] [c[PII_REDACTED]4b14c] dma_set_mask+0x3c/0x80
[c00001400c9ffd00] [c[PII_REDACTED]b715c] be_probe+0xc4/0xb90 [be2net]
[c00001400c9ffdc0] [c[PII_REDACTED]86f3c] local_pci_probe+0x6c/0x110
[c00001400c9ffe40] [c[PII_REDACTED]88f28] work_for_cpu_fn+0x38/0x60
[c00001400c9ffe70] [c[PII_REDACTED]8e454] process_one_work+0x314/0x620
[c00001400c9fff10] [c[PII_REDACTED]8f280] worker_thread+0x2b0/0x620
[c00001400c9fff90] [c[PII_REDACTED]9bb18] kthread+0x148/0x150
[c00001400c9fffe0] [c[PII_REDACTED]0ded8] start_kernel_thread+0x14/0x18

There are 2 issues in the code

1. The index is "int" while the address is "unsigned long". This results in
   negative value when setting the bitmap.

2. The DMA offset is page shifted but the MMIO range is used as-is (64-bit
   address). MMIO address needs to be page shifted as well.
CVSS Score: 5.5 (MEDIUM)
References: https://git.kernel.org/stable/c/7043d58ecd1381674f5b2c894deb6986a1a4896b; https://git.kernel.org/stable/c/8f70caad82e9c088ed93b4fea48d941ab6441886; https://git.kernel.org/stable/c/d8cc20a8cceb3b5e8ad2e11365e3100ba36a27e9