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 40D4882481 for ; Wed, 17 Apr 2024 10:30:44 +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=1713349845; cv=none; b=qkNGRemUekTH8QU5rtUzkVk5BEIbdD6KCRuz4A7Ab9yjLMiRvKfTiXqJ/xVPq21uG+foOLi54ENXGlmDrixXtSq7pOHcq2rBpzAmoFbVPLKNqjA2fWIrlKh+aE4oVulveXMIaASX5aZnkw53VvgiUsw1Knjx/R/TsqHYvESCdv0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713349845; c=relaxed/simple; bh=0EIuID1RPjxpHnXo3Jmfj2WNRc6iY3OXZMrz+sKle6A=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=GbQ3ge9Q4CI4sSoC+X7392ugL43nv3b0bZ1ygNUYHeG7jRdKI9cSNIFx5e0O8TCy2u6UuTnGF3zgqw7ILvgw36qkkfU+ADWcUP8OwCuN9FHgUvrn0CBl8E9AhAa8uRNDPYGT4bCmYSztdHAOdIOEAV14fSvqXdHeGwRGwJaGcRc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=RwRdrfyb; 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="RwRdrfyb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 752C5C072AA; Wed, 17 Apr 2024 10:30:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1713349844; bh=0EIuID1RPjxpHnXo3Jmfj2WNRc6iY3OXZMrz+sKle6A=; h=From:To:Cc:Subject:Date:Reply-to:From; b=RwRdrfyblVe05G6/WMT0SujQ2Px/cHjgmrBGpizI2L/irjUIFJrAtHzSAOJmyccSr 7YSPGCc1e5J6K5VA3fRqFoPAFSPvYhY4pBCt694ziHpRMoqDJHfV24SM3KGohbwNGX hSGFO2Q0fvwmerlIe1b1OeSRM72BI9MC/35zTJp4= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-26902: perf: RISCV: Fix panic on pmu overflow handler Date: Wed, 17 Apr 2024 12:29:17 +0200 Message-ID: <2024041745-CVE-2024-26902-5f77@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=3825; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=0EIuID1RPjxpHnXo3Jmfj2WNRc6iY3OXZMrz+sKle6A=; b=owGbwMvMwCRo6H6F97bub03G02pJDGnyS2JNnnzYP0mjaXFZvKyY1YKCHgNd+d0RmZ6edoW1d VOjJnF1xLIwCDIxyIopsnzZxnN0f8UhRS9D29Mwc1iZQIYwcHEKwEQUChjml0yxT2G0+lVT7xgW oMR49z/nSe19DPMzg3uLHxV8uzFhpUrZHqaCrSaun9cBAA== 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: perf: RISCV: Fix panic on pmu overflow handler (1 << idx) of int is not desired when setting bits in unsigned long overflowed_ctrs, use BIT() instead. This panic happens when running 'perf record -e branches' on sophgo sg2042. [ 273.311852] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000098 [ 273.320851] Oops [#1] [ 273.323179] Modules linked in: [ 273.326303] CPU: 0 PID: 1475 Comm: perf Not tainted 6.6.0-rc3+ #9 [ 273.332521] Hardware name: Sophgo Mango (DT) [ 273.336878] epc : riscv_pmu_ctr_get_width_mask+0x8/0x62 [ 273.342291] ra : pmu_sbi_ovf_handler+0x2e0/0x34e [ 273.347091] epc : ffffffff80aecd98 ra : ffffffff80aee056 sp : fffffff6e36928b0 [ 273.354454] gp : ffffffff821f82d0 tp : ffffffd90c353200 t0 : 0000002ade4f9978 [ 273.361815] t1 : 0000000000504d55 t2 : ffffffff8016cd8c s0 : fffffff6e3692a70 [ 273.369180] s1 : 0000000000000020 a0 : 0000000000000000 a1 : 00001a8e81800000 [ 273.376540] a2 : 0000003c00070198 a3 : 0000003c00db75a4 a4 : 0000000000000015 [ 273.383901] a5 : ffffffd7ff8804b0 a6 : 0000000000000015 a7 : 000000000000002a [ 273.391327] s2 : 000000000000ffff s3 : 0000000000000000 s4 : ffffffd7ff8803b0 [ 273.398773] s5 : 0000000000504d55 s6 : ffffffd905069800 s7 : ffffffff821fe210 [ 273.406139] s8 : 000000007fffffff s9 : ffffffd7ff8803b0 s10: ffffffd903f29098 [ 273.413660] s11: 0000000080000000 t3 : 0000000000000003 t4 : ffffffff8017a0ca [ 273.421022] t5 : ffffffff8023cfc2 t6 : ffffffd9040780e8 [ 273.426437] status: 0000000200000100 badaddr: 0000000000000098 cause: 000000000000000d [ 273.434512] [] riscv_pmu_ctr_get_width_mask+0x8/0x62 [ 273.441169] [] handle_percpu_devid_irq+0x98/0x1ee [ 273.447562] [] generic_handle_domain_irq+0x28/0x36 [ 273.454151] [] riscv_intc_irq+0x36/0x4e [ 273.459659] [] handle_riscv_irq+0x4a/0x74 [ 273.465442] [] do_irq+0x62/0x92 [ 273.470360] Code: 0420 60a2 6402 5529 0141 8082 0013 0000 0013 0000 (6d5c) b783 [ 273.477921] ---[ end trace 0000000000000000 ]--- [ 273.482630] Kernel panic - not syncing: Fatal exception in interrupt The Linux kernel CVE team has assigned CVE-2024-26902 to this issue. Affected and fixed versions =========================== Fixed in 6.6.23 with commit 3ede8e94de6b Fixed in 6.7.11 with commit 9f599ba3b9cc Fixed in 6.8 with commit 34b567868777 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-26902 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/perf/riscv_pmu_sbi.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/3ede8e94de6b834b48b0643385e66363e7a04be9 https://git.kernel.org/stable/c/9f599ba3b9cc4bdb8ec1e3f0feddd41bf9d296d6 https://git.kernel.org/stable/c/34b567868777e9fd39ec5333969728a7f0cf179c