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 F06E77262A for ; Tue, 9 Dec 2025 00:05:02 +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=1765238703; cv=none; b=YFg6nht9CS1w1klyVkyXBxaYYcdGqG4E9mZEizs2E8Jmxp0EhmpVbGkHXLnIBbabvZtSNqpYGbSOvzE807VXh4XxkM9FjDg7yyc+VowbVvblKKOwDOTo50Y2eh5FWWxd33xK5O7OiPapJEMD3gEAJEnzhuW5J0APhhhuhRQlhzU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765238703; c=relaxed/simple; bh=WYGqMq4QmJTAfifiYBGo4UMACoqE1v6JEAtNq6+qwes=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=p3/MtTPQlQ8/HwRQ7SOjbdDvP6MQ7f3OUIyji2jZnFtXSmJZBQrLke63oQIWkbWH1644Xod6sUYdQHj8GsfJT2P8+58NcIEDGUds4U4YZgfd2JaozxPn1/uVMeaA5AU69kUdbSap/rOrR6Ld2/eltpYW4ru/pBC6zkSGCELJ4EU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xG2H7UT5; 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="xG2H7UT5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DF81C4CEF1; Tue, 9 Dec 2025 00:05:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1765238702; bh=WYGqMq4QmJTAfifiYBGo4UMACoqE1v6JEAtNq6+qwes=; h=From:To:Cc:Subject:Date:Reply-To:From; b=xG2H7UT5QDVF2Z8PRS7PftfVHkRpBhhF+/LroK+f/0k28Z3WQ8rF5Ik6fqM6TTs5g pX4PQ+b9AqwZ+FcZq7U4XWrnC97JYkncURHk8i3LXLluxTEfLtm3Oh3e/2sImadlVI fO9RZI7dLF9MDRsoq5JzXjUIiVtCazPzBVdFrj1E= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-50654: bpf: Fix panic due to wrong pageattr of im->image Date: Tue, 9 Dec 2025 09:01:55 +0900 Message-ID: <2025120938-CVE-2022-50654-a5d9@gregkh> X-Mailer: git-send-email 2.52.0 Reply-To: , Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4078; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=luwa8UgXBEhPSVDCwr51VEJl2csSrGLNPG7/6gg1eZA=; b=owGbwMvMwCRo6H6F97bub03G02pJDJnmaY9qMkMnMmzqUXu7wvn615t3T8zMDXjo/zrJTPzvp vkmpzdd7YhlYRBkYpAVU2T5so3n6P6KQ4pehranYeawMoEMYeDiFICJ6K9mmB+6uPbjf/uqhas6 ZmtZBUikR7/m/sQwP/DT/NjFh0srF977WC8WcPPxyj//CwA= 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: bpf: Fix panic due to wrong pageattr of im->image In the scenario where livepatch and kretfunc coexist, the pageattr of im->image is rox after arch_prepare_bpf_trampoline in bpf_trampoline_update, and then modify_fentry or register_fentry returns -EAGAIN from bpf_tramp_ftrace_ops_func, the BPF_TRAMP_F_ORIG_STACK flag will be configured, and arch_prepare_bpf_trampoline will be re-executed. At this time, because the pageattr of im->image is rox, arch_prepare_bpf_trampoline will read and write im->image, which causes a fault. as follows: insmod livepatch-sample.ko # samples/livepatch/livepatch-sample.c bpftrace -e 'kretfunc:cmdline_proc_show {}' BUG: unable to handle page fault for address: ffffffffa0206000 PGD 322d067 P4D 322d067 PUD 322e063 PMD 1297e067 PTE d428061 Oops: 0003 [#1] PREEMPT SMP PTI CPU: 2 PID: 270 Comm: bpftrace Tainted: G E K 6.1.0 #5 RIP: 0010:arch_prepare_bpf_trampoline+0xed/0x8c0 RSP: 0018:ffffc90001083ad8 EFLAGS: 00010202 RAX: ffffffffa0206000 RBX: 0000000000000020 RCX: 0000000000000000 RDX: ffffffffa0206001 RSI: ffffffffa0206000 RDI: 0000000000000030 RBP: ffffc90001083b70 R08: 0000000000000066 R09: ffff88800f51b400 R10: 000000002e72c6e5 R11: 00000000d0a15080 R12: ffff8880110a68c8 R13: 0000000000000000 R14: ffff88800f51b400 R15: ffffffff814fec10 FS: 00007f87bc0dc780(0000) GS:ffff88803e600000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffa0206000 CR3: 0000000010b70000 CR4: 00000000000006e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: bpf_trampoline_update+0x25a/0x6b0 __bpf_trampoline_link_prog+0x101/0x240 bpf_trampoline_link_prog+0x2d/0x50 bpf_tracing_prog_attach+0x24c/0x530 bpf_raw_tp_link_attach+0x73/0x1d0 __sys_bpf+0x100e/0x2570 __x64_sys_bpf+0x1c/0x30 do_syscall_64+0x5b/0x80 entry_SYSCALL_64_after_hwframe+0x63/0xcd With this patch, when modify_fentry or register_fentry returns -EAGAIN from bpf_tramp_ftrace_ops_func, the pageattr of im->image will be reset to nx+rw. The Linux kernel CVE team has assigned CVE-2022-50654 to this issue. Affected and fixed versions =========================== Issue introduced in 6.0 with commit 00963a2e75a872e5fce4d0115ac2786ec86b57a6 and fixed in 6.0.19 with commit d9d383cbf812a3b4094c089aa5f5d41a3bb4531d Issue introduced in 6.0 with commit 00963a2e75a872e5fce4d0115ac2786ec86b57a6 and fixed in 6.1.5 with commit 7f656fff955ccb216c40fa188a24c05fa40985a5 Issue introduced in 6.0 with commit 00963a2e75a872e5fce4d0115ac2786ec86b57a6 and fixed in 6.2 with commit 9ed1d9aeef5842ecacb660fce933613b58af1e00 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-2022-50654 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/trampoline.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/d9d383cbf812a3b4094c089aa5f5d41a3bb4531d https://git.kernel.org/stable/c/7f656fff955ccb216c40fa188a24c05fa40985a5 https://git.kernel.org/stable/c/9ed1d9aeef5842ecacb660fce933613b58af1e00