From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BED845970 for ; Thu, 4 Apr 2024 08:23:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712218994; cv=none; b=EhYbx+M6msBUfmE39IbXvm0RkDrvYPAs3ls7l9fF8iuUtoNAZk4iu5/j7Yqi+FEXXzsCoOPeSuSloDiqReG/TZdi+z804PO10xJZsTLqspVL/OJvEybU9/GZJQn9JK1Yx3v9QgrZJEejU9G5SX3AXj7PjuaiLper2wh/UjHruh8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712218994; c=relaxed/simple; bh=FvoBHpT5EWQTomgcNeEmCt1WU7nsvS8EFsLCF1jHV8g=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=DOY+bIifQD/fIMOS3pbTBJSu/T3T64Pt8Y4YywxOOVX2xnFQWp7pssKnNSg4vZ6veayLIW4vrVe356vxafsSfWKjp76ntccsitVuGe8K9fT3e5I2Q42utizKZ4WBV+pxpvAC3ZKel3ao8UIHGZTzHLXQ3G9ZhPxhIYy2rCNkwFQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HynmLNnA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="HynmLNnA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53005C433F1; Thu, 4 Apr 2024 08:23:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1712218993; bh=FvoBHpT5EWQTomgcNeEmCt1WU7nsvS8EFsLCF1jHV8g=; h=From:To:Cc:Subject:Date:Reply-to:From; b=HynmLNnAUQVaAan3pfP61yt2UjPRGD9QlaSRVOLWEI00anq0q7whgRl/xljSjZPqP stSlGu2dfbPVpkk4lGlBr2GiWBrMGfIcpsxrQSzhVdHQ31qrTDOd7n7Th95gOxihcN tGyDHpMrZCRAX1ZNmb9jVb00nK7gG49w1DZUwj7Q= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-26745: powerpc/pseries/iommu: IOMMU table is not initialized for kdump over SR-IOV Date: Thu, 4 Apr 2024 10:22:54 +0200 Message-ID: <2024040454-CVE-2024-26745-fa88@gregkh> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=5804; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=FvoBHpT5EWQTomgcNeEmCt1WU7nsvS8EFsLCF1jHV8g=; b=owGbwMvMwCRo6H6F97bub03G02pJDGl8yXHBAi/fnJeLWnZ3Q8yV1uqCffE3xXRt3sfGZdYfD l+coH+rI5aFQZCJQVZMkeXLNp6j+ysOKXoZ2p6GmcPKBDKEgYtTACZyfAPDgmOXtimsdXDIEjtn 8Uxzrspx94lN7xgWHJ20YfcD/nusWVcP/V91Y6Xc6jdT/gAA X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: powerpc/pseries/iommu: IOMMU table is not initialized for kdump over SR-IOV When kdump kernel tries to copy dump data over SR-IOV, LPAR panics due to NULL pointer exception: Kernel attempted to read user page (0) - exploit attempt? (uid: 0) BUG: Kernel NULL pointer dereference on read at 0x00000000 Faulting instruction address: 0xc000000020847ad4 Oops: Kernel access of bad area, sig: 11 [#1] LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA pSeries Modules linked in: mlx5_core(+) vmx_crypto pseries_wdt papr_scm libnvdimm mlxfw tls psample sunrpc fuse overlay squashfs loop CPU: 12 PID: 315 Comm: systemd-udevd Not tainted 6.4.0-Test102+ #12 Hardware name: IBM,9080-HEX POWER10 (raw) 0x800200 0xf000006 of:IBM,FW1060.00 (NH1060_008) hv:phyp pSeries NIP: c000000020847ad4 LR: c00000002083b2dc CTR: 00000000006cd18c REGS: c000000029162ca0 TRAP: 0300 Not tainted (6.4.0-Test102+) MSR: 800000000280b033 CR: 48288244 XER: 00000008 CFAR: c00000002083b2d8 DAR: 0000000000000000 DSISR: 40000000 IRQMASK: 1 ... NIP _find_next_zero_bit+0x24/0x110 LR bitmap_find_next_zero_area_off+0x5c/0xe0 Call Trace: dev_printk_emit+0x38/0x48 (unreliable) iommu_area_alloc+0xc4/0x180 iommu_range_alloc+0x1e8/0x580 iommu_alloc+0x60/0x130 iommu_alloc_coherent+0x158/0x2b0 dma_iommu_alloc_coherent+0x3c/0x50 dma_alloc_attrs+0x170/0x1f0 mlx5_cmd_init+0xc0/0x760 [mlx5_core] mlx5_function_setup+0xf0/0x510 [mlx5_core] mlx5_init_one+0x84/0x210 [mlx5_core] probe_one+0x118/0x2c0 [mlx5_core] local_pci_probe+0x68/0x110 pci_call_probe+0x68/0x200 pci_device_probe+0xbc/0x1a0 really_probe+0x104/0x540 __driver_probe_device+0xb4/0x230 driver_probe_device+0x54/0x130 __driver_attach+0x158/0x2b0 bus_for_each_dev+0xa8/0x130 driver_attach+0x34/0x50 bus_add_driver+0x16c/0x300 driver_register+0xa4/0x1b0 __pci_register_driver+0x68/0x80 mlx5_init+0xb8/0x100 [mlx5_core] do_one_initcall+0x60/0x300 do_init_module+0x7c/0x2b0 At the time of LPAR dump, before kexec hands over control to kdump kernel, DDWs (Dynamic DMA Windows) are scanned and added to the FDT. For the SR-IOV case, default DMA window "ibm,dma-window" is removed from the FDT and DDW added, for the device. Now, kexec hands over control to the kdump kernel. When the kdump kernel initializes, PCI busses are scanned and IOMMU group/tables created, in pci_dma_bus_setup_pSeriesLP(). For the SR-IOV case, there is no "ibm,dma-window". The original commit: b1fc44eaa9ba, fixes the path where memory is pre-mapped (direct mapped) to the DDW. When TCEs are direct mapped, there is no need to initialize IOMMU tables. iommu_table_setparms_lpar() only considers "ibm,dma-window" property when initiallizing IOMMU table. In the scenario where TCEs are dynamically allocated for SR-IOV, newly created IOMMU table is not initialized. Later, when the device driver tries to enter TCEs for the SR-IOV device, NULL pointer execption is thrown from iommu_area_alloc(). The fix is to initialize the IOMMU table with DDW property stored in the FDT. There are 2 points to remember: 1. For the dedicated adapter, kdump kernel would encounter both default and DDW in FDT. In this case, DDW property is used to initialize the IOMMU table. 2. A DDW could be direct or dynamic mapped. kdump kernel would initialize IOMMU table and mark the existing DDW as "dynamic". This works fine since, at the time of table initialization, iommu_table_clear() makes some space in the DDW, for some predefined number of TCEs which are needed for kdump to succeed. The Linux kernel CVE team has assigned CVE-2024-26745 to this issue. Affected and fixed versions =========================== Issue introduced in 6.0 with commit b1fc44eaa9ba and fixed in 6.1.81 with commit 7eb95e0af5c9 Issue introduced in 6.0 with commit b1fc44eaa9ba and fixed in 6.6.21 with commit d4d1e4b1513d Issue introduced in 6.0 with commit b1fc44eaa9ba and fixed in 6.7.9 with commit 5da6d306f315 Issue introduced in 6.0 with commit b1fc44eaa9ba and fixed in 6.8 with commit 09a3c1e46142 Issue introduced in 5.18.18 with commit b9f08b2649dd Issue introduced in 5.19.2 with commit 58942f672c6d Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2024-26745 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: arch/powerpc/platforms/pseries/iommu.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/7eb95e0af5c9c2e6fad50356eaf32d216d0e7bc3 https://git.kernel.org/stable/c/d4d1e4b1513d975961de7bb4f75e450a92d65ebf https://git.kernel.org/stable/c/5da6d306f315344af1ca2eff4bd9b10b130f0c28 https://git.kernel.org/stable/c/09a3c1e46142199adcee372a420b024b4fc61051