CVE-2021-47317: powerpc/bpf: Fix detecting BPF atomic instructions
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
powerpc/bpf: Fix detecting BPF atomic instructions
Commit 91c960b0056672 ("bpf: Rename BPF_XADD and prepare to encode other atomics in .imm") converted BPF_XADD to BPF_ATOMIC and added a way to distinguish instructions based on the immediate field. Existing JIT implementations were updated to check for the immediate field and to reject programs utilizing anything more than BPF_ADD (such as BPF_FETCH) in the immediate field.
However, the check added to powerpc64 JIT did not look at the correct BPF instruction. Due to this, such programs would be accepted and incorrectly JIT'ed resulting in soft lockups, as seen with the atomic bounds test. Fix this by looking at the correct immediate value.
The Linux kernel CVE team has assigned CVE-2021-47317 to this issue.
Affected and fixed versions
===========================
Issue introduced in 5.12 with commit 91c960b00566 and fixed in 5.12.19 with commit 7284dab07e4d Issue introduced in 5.12 with commit 91c960b00566 and fixed in 5.13.4 with commit 0d435b6d94b0 Issue introduced in 5.12 with commit 91c960b00566 and fixed in 5.14 with commit 419ac821766c
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-2021-47317
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:
arch/powerpc/net/bpf_jit_comp64.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/7284dab07e4d51d453cc42851fae9ec4fac6ef2f https://git.kernel.org/stable/c/0d435b6d94b05dcfd836d758a63145aa566618e2 https://git.kernel.org/stable/c/419ac821766cbdb9fd85872bb3f1a589df05c94c