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 A81D5145A02 for ; Tue, 21 May 2024 15:37:30 +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=1716305851; cv=none; b=ZViuaiCeBY0vdFfE3n3vIaomHQ0fKgMx8a//gJbYX7QCoSY0/HQkod8i91W7mLG09JrRW5WeozGBuppUxsKF1t99aON34sluivBGsF+Grz9ExZ5UWXEJJUOZEn/WfR7c8YSJ/XDyStqxVgQn1BV5AAURT+Ccs/WXirjJXKS3ExE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716305851; c=relaxed/simple; bh=fk96rUAS05FtTsfs44NdqwbgWs/2aEEWZ1cywemJ/Xg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=GtmTwyQJanduCxJWWRbHGiDKxhudFO5Jw222pOQ3YEFUnXr7QYRFxjBVWzVmJjrJ/U7036Jv/G4wJxgFsmQLRZZOtT/rV9B8N0q4RQlvazZ4l1iqBRQpvuZvj4dq1UfFCTBbkao+0LaR7ZbAk5ULb4dRoZrsE2bT/xy5DywxRKM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=GeArJRrd; 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="GeArJRrd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35964C2BD11; Tue, 21 May 2024 15:37:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1716305850; bh=fk96rUAS05FtTsfs44NdqwbgWs/2aEEWZ1cywemJ/Xg=; h=From:To:Cc:Subject:Date:Reply-to:From; b=GeArJRrd+CPMxzISwh19VoaXVCfnXwjnKbu3EA5BFD/Ff7PSdqrckCJL1Kp4YAq1b dRqXp7zZeG8HDjkC8Ei8jbsy1J9G3wdgp/y2PUDNUdZg33+ptGIQZ2RxvbgduTWaaF JzniUA4NQ/WLcWu5sYLRPJ/Gu/fK1vPJKjL4aU3A= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2023-52828: bpf: Detect IP == ksym.end as part of BPF program Date: Tue, 21 May 2024 17:32:04 +0200 Message-ID: <2024052107-CVE-2023-52828-e1e5@gregkh> X-Mailer: git-send-email 2.45.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=3867; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=fk96rUAS05FtTsfs44NdqwbgWs/2aEEWZ1cywemJ/Xg=; b=owGbwMvMwCRo6H6F97bub03G02pJDGk++6y/eV69rvXdMGXj1d/yNhbft1uvLrOb0P5lR/nah C1/cl/ad8SyMAgyMciKKbJ82cZzdH/FIUUvQ9vTMHNYmUCGMHBxCsBEEjQZ5nDyOC+YWXHN5vbm prUXenVEOTvurWZYcNhf8nX1Q5nrcyqVNXwSbFVPnTx2BgA= 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: bpf: Detect IP == ksym.end as part of BPF program Now that bpf_throw kfunc is the first such call instruction that has noreturn semantics within the verifier, this also kicks in dead code elimination in unprecedented ways. For one, any instruction following a bpf_throw call will never be marked as seen. Moreover, if a callchain ends up throwing, any instructions after the call instruction to the eventually throwing subprog in callers will also never be marked as seen. The tempting way to fix this would be to emit extra 'int3' instructions which bump the jited_len of a program, and ensure that during runtime when a program throws, we can discover its boundaries even if the call instruction to bpf_throw (or to subprogs that always throw) is emitted as the final instruction in the program. An example of such a program would be this: do_something(): ... r0 = 0 exit foo(): r1 = 0 call bpf_throw r0 = 0 exit bar(cond): if r1 != 0 goto pc+2 call do_something exit call foo r0 = 0 // Never seen by verifier exit // main(ctx): r1 = ... call bar r0 = 0 exit Here, if we do end up throwing, the stacktrace would be the following: bpf_throw foo bar main In bar, the final instruction emitted will be the call to foo, as such, the return address will be the subsequent instruction (which the JIT emits as int3 on x86). This will end up lying outside the jited_len of the program, thus, when unwinding, we will fail to discover the return address as belonging to any program and end up in a panic due to the unreliable stack unwinding of BPF programs that we never expect. To remedy this case, make bpf_prog_ksym_find treat IP == ksym.end as part of the BPF program, so that is_bpf_text_address returns true when such a case occurs, and we are able to unwind reliably when the final instruction ends up being a call instruction. The Linux kernel CVE team has assigned CVE-2023-52828 to this issue. Affected and fixed versions =========================== Fixed in 5.10.202 with commit 6058e4829696 Fixed in 5.15.140 with commit cf353904a828 Fixed in 6.1.64 with commit aa42a7cb9264 Fixed in 6.5.13 with commit 327b92e8cb52 Fixed in 6.6.3 with commit 821a7e4143af Fixed in 6.7 with commit 66d9111f3517 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-2023-52828 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: kernel/bpf/core.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/6058e4829696412457729a00734969acc6fd1d18 https://git.kernel.org/stable/c/cf353904a82873e952633fcac4385c2fcd3a46e1 https://git.kernel.org/stable/c/aa42a7cb92647786719fe9608685da345883878f https://git.kernel.org/stable/c/327b92e8cb527ae097961ffd1610c720481947f5 https://git.kernel.org/stable/c/821a7e4143af115b840ec199eb179537e18af922 https://git.kernel.org/stable/c/66d9111f3517f85ef2af0337ece02683ce0faf21