| From bippy-1.2.0 Mon Sep 17 00:00:00 2001 |
| From: Greg Kroah-Hartman <gregkh@kernel.org> |
| To: <linux-cve-announce@vger.kernel.org> |
| Reply-to: <cve@kernel.org>, <linux-kernel@vger.kernel.org> |
| Subject: CVE-2024-58237: bpf: consider that tail calls invalidate packet pointers |
| |
| Description |
| =========== |
| |
| In the Linux kernel, the following vulnerability has been resolved: |
| |
| bpf: consider that tail calls invalidate packet pointers |
| |
| Tail-called programs could execute any of the helpers that invalidate |
| packet pointers. Hence, conservatively assume that each tail call |
| invalidates packet pointers. |
| |
| Making the change in bpf_helper_changes_pkt_data() automatically makes |
| use of check_cfg() logic that computes 'changes_pkt_data' effect for |
| global sub-programs, such that the following program could be |
| rejected: |
| |
| int tail_call(struct __sk_buff *sk) |
| { |
| bpf_tail_call_static(sk, &jmp_table, 0); |
| return 0; |
| } |
| |
| SEC("tc") |
| int not_safe(struct __sk_buff *sk) |
| { |
| int *p = (void *)(long)sk->data; |
| ... make p valid ... |
| tail_call(sk); |
| *p = 42; /* this is unsafe */ |
| ... |
| } |
| |
| The tc_bpf2bpf.c:subprog_tc() needs change: mark it as a function that |
| can invalidate packet pointers. Otherwise, it can't be freplaced with |
| tailcall_freplace.c:entry_freplace() that does a tail call. |
| |
| The Linux kernel CVE team has assigned CVE-2024-58237 to this issue. |
| |
| |
| Affected and fixed versions |
| =========================== |
| |
| Issue introduced in 5.6 with commit 51c39bb1d5d105a02e29aa7960f0a395086e6342 and fixed in 6.6.90 with commit f1692ee23dcaaddc24ba407b269707ee5df1301f |
| Issue introduced in 5.6 with commit 51c39bb1d5d105a02e29aa7960f0a395086e6342 and fixed in 6.12.9 with commit 1c2244437f9ad3dd91215f920401a14f2542dbfc |
| Issue introduced in 5.6 with commit 51c39bb1d5d105a02e29aa7960f0a395086e6342 and fixed in 6.13 with commit 1a4607ffba35bf2a630aab299e34dd3f6e658d70 |
| |
| 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-58237 |
| 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: |
| net/core/filter.c |
| tools/testing/selftests/bpf/progs/tc_bpf2bpf.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/f1692ee23dcaaddc24ba407b269707ee5df1301f |
| https://git.kernel.org/stable/c/1c2244437f9ad3dd91215f920401a14f2542dbfc |
| https://git.kernel.org/stable/c/1a4607ffba35bf2a630aab299e34dd3f6e658d70 |