bpf: fix constant blinding bypass for PROBE_MEM32 stores#11312
bpf: fix constant blinding bypass for PROBE_MEM32 stores#11312kernel-patches-daemon-bpf[bot] wants to merge 1 commit intobpf_basefrom
Conversation
|
Upstream branch: 56145d2 |
6a02b42 to
2f859eb
Compare
|
Upstream branch: 6895e1d |
d60f206 to
62f84fa
Compare
2f859eb to
50410e9
Compare
|
Upstream branch: 325d1ba |
62f84fa to
91c7529
Compare
50410e9 to
a0a27bf
Compare
|
Upstream branch: b0dcdcb |
91c7529 to
51cef27
Compare
a0a27bf to
cbcec6d
Compare
|
Upstream branch: 1954c4f |
51cef27 to
4de0f29
Compare
cbcec6d to
96755db
Compare
|
Upstream branch: 014441d |
4de0f29 to
3f16f10
Compare
96755db to
80bf62c
Compare
|
Upstream branch: 1f318b9 |
3f16f10 to
173b782
Compare
|
Upstream branch: 1f318b9 |
173b782 to
0cbc6c3
Compare
To: bpf@vger.kernel.org Cc: daniel@iogearbox.net, ast@kernel.org, andrii@kernel.org, netdev@vger.kernel.org Subject: [PATCH bpf v2] bpf: fix constant blinding bypass for PROBE_MEM32 stores BPF_ST | BPF_PROBE_MEM32 immediate stores are not handled by bpf_jit_blind_insn(), allowing user-controlled 32-bit immediates to survive unblinded into JIT-compiled native code when bpf_jit_harden >= 1. The root cause is that convert_ctx_accesses() rewrites BPF_ST|BPF_MEM to BPF_ST|BPF_PROBE_MEM32 for arena pointer stores during verification, before bpf_jit_blind_constants() runs during JIT compilation. The blinding switch only matches BPF_ST|BPF_MEM (mode 0x60), not BPF_ST|BPF_PROBE_MEM32 (mode 0xa0). The instruction falls through unblinded. Add BPF_ST|BPF_PROBE_MEM32 cases to bpf_jit_blind_insn() alongside the existing BPF_ST|BPF_MEM cases. The blinding transformation is identical: load the blinded immediate into BPF_REG_AX via mov+xor, then convert the immediate store to a register store (BPF_STX). The rewritten STX instruction must preserve the BPF_PROBE_MEM32 mode so the architecture JIT emits the correct arena addressing (R12-based on x86-64). Cannot use the BPF_STX_MEM() macro here because it hardcodes BPF_MEM mode; construct the instruction directly instead. Fixes: 6082b6c ("bpf: Recognize addr_space_cast instruction in the verifier.") Signed-off-by: s4ch <xcyfun@protonmail.com> Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com> Reviewed-by: Puranjay Mohan <puranjay@kernel.org>
|
Upstream branch: 1f318b9 |
0cbc6c3 to
c4f7c28
Compare
|
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=1062438 expired. Closing PR. |
Pull request for series with
subject: bpf: fix constant blinding bypass for PROBE_MEM32 stores
version: 2
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1062438