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 E89A72ECD1C for ; Fri, 25 Jul 2025 12:56:27 +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=1753448188; cv=none; b=pRs94fh2eZR0y+F5YOI/bJSEK3OGMIyrTwLp+sXhpXl97rKf+/3n36RtVFpaas3AHNbeVb61gJyxkuOaW+tfZwKZvKUqflVDP2L4m3bvZOwXAyMqtoHlRDI4lhEdpHLrE7PW9Xmg48bYpntVHxA4aZpKjLyZWbo7mldkUZcWifA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753448188; c=relaxed/simple; bh=WUKzOk8sQji0mlw9lJstIdeQaR81XdeZts4fH/zvPN8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=X5cGx9op3XvH1PEMaHFBaL+5fd2O2i4VHbgKWn3iYdmPoXNgFLnmTTRLl1rg+ic0sZ6w8QUFUE2ABN3Eo6spRDlTCUihq3Rmvn/OEo8UbCpYkXES7/nLFchXVCIhIPQ29tWs4vCLvr6NYh+X42PTs/L7KYlZmVaIbnLHUZuSzZc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ZTWLdYu3; 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="ZTWLdYu3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56F93C4CEE7; Fri, 25 Jul 2025 12:56:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1753448187; bh=WUKzOk8sQji0mlw9lJstIdeQaR81XdeZts4fH/zvPN8=; h=From:To:Cc:Subject:Date:Reply-to:From; b=ZTWLdYu3dVtGVPi4sY1Mvd2/ldk1rBCBpe3Xz9nO6LUIKVZMk0+eFKlFJsv2S16bm 0KPuQNqICQ8RZJ2xchohXq5VtjnEQKE1JfA4q4bAyUZVuGEabRy46r/WQdjblm4pvr S0YDQglWwBGkBB6OgDv7j5WiZdZxbs4jgytozDus= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-38398: spi: spi-qpic-snand: reallocate BAM transactions Date: Fri, 25 Jul 2025 14:55:29 +0200 Message-ID: <2025072510-CVE-2025-38398-1271@gregkh> X-Mailer: git-send-email 2.50.1 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=3728; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=Wcv0dabm7mSXaT1K1UnqHbMOMrQdm44IqnZtWfH5d1Y=; b=owGbwMvMwCRo6H6F97bub03G02pJDBnNdetYvbf6y91MSlh4Raw/9Nwihk87kv3kre0fef24H uuRP+ddRywLgyATg6yYIsuXbTxH91ccUvQytD0NM4eVCWQIAxenAEwku4lhwcFrQU4Hw/9e50rT dDB6o1wzO737NsP8CPHeN3mzJPbzSNzcFGnCYKr+f/86AA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== In the Linux kernel, the following vulnerability has been resolved: spi: spi-qpic-snand: reallocate BAM transactions Using the mtd_nandbiterrs module for testing the driver occasionally results in weird things like below. 1. swiotlb mapping fails with the following message: [ 85.926216] qcom_snand 79b0000.spi: swiotlb buffer is full (sz: 4294967294 bytes), total 512 (slots), used 0 (slots) [ 85.932937] qcom_snand 79b0000.spi: failure in mapping desc [ 87.999314] qcom_snand 79b0000.spi: failure to write raw page [ 87.999352] mtd_nandbiterrs: error: write_oob failed (-110) Rebooting the board after this causes a panic due to a NULL pointer dereference. 2. If the swiotlb mapping does not fail, rebooting the board may result in a different panic due to a bad spinlock magic: [ 256.104459] BUG: spinlock bad magic on CPU#3, procd/2241 [ 256.104488] Unable to handle kernel paging request at virtual address ffffffff0000049b ... Investigating the issue revealed that these symptoms are results of memory corruption which is caused by out of bounds access within the driver. The driver uses a dynamically allocated structure for BAM transactions, which structure must have enough space for all possible variations of different flash operations initiated by the driver. The required space heavily depends on the actual number of 'codewords' which is calculated from the pagesize of the actual NAND chip. Although the qcom_nandc_alloc() function allocates memory for the BAM transactions during probe, but since the actual number of 'codewords' is not yet know the allocation is done for one 'codeword' only. Because of this, whenever the driver does a flash operation, and the number of the required transactions exceeds the size of the allocated arrays the driver accesses memory out of the allocated range. To avoid this, change the code to free the initially allocated BAM transactions memory, and allocate a new one once the actual number of 'codewords' required for a given NAND chip is known. The Linux kernel CVE team has assigned CVE-2025-38398 to this issue. Affected and fixed versions =========================== Issue introduced in 6.15 with commit 7304d1909080ef0c9da703500a97f46c98393fcd and fixed in 6.15.6 with commit 86fb36de1132b560f9305f0c78fa69f459fa0980 Issue introduced in 6.15 with commit 7304d1909080ef0c9da703500a97f46c98393fcd and fixed in 6.16-rc5 with commit d85d0380292a7e618915069c3579ae23c7c80339 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-2025-38398 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: drivers/spi/spi-qpic-snand.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/86fb36de1132b560f9305f0c78fa69f459fa0980 https://git.kernel.org/stable/c/d85d0380292a7e618915069c3579ae23c7c80339