Skip to content

bpf: fix constant blinding bypass for PROBE_MEM32 stores#11340

Closed
kernel-patches-daemon-bpf[bot] wants to merge 2 commits intobpf_basefrom
series/1063861=>bpf
Closed

bpf: fix constant blinding bypass for PROBE_MEM32 stores#11340
kernel-patches-daemon-bpf[bot] wants to merge 2 commits intobpf_basefrom
series/1063861=>bpf

Conversation

@kernel-patches-daemon-bpf
Copy link

Pull request for series with
subject: bpf: fix constant blinding bypass for PROBE_MEM32 stores
version: 4
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1063861

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 1f318b9
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1063861
version: 4

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 1f318b9
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1063861
version: 4

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 1f318b9
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1063861
version: 4

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: ac72464
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1063861
version: 4

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.")
Reviewed-by: Puranjay Mohan <puranjay@kernel.org>
Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com>
Signed-off-by: Sachin Kumar <xcyfun@protonmail.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
@kernel-patches-daemon-bpf
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=1063861 irrelevant now. Closing PR.

@kernel-patches-daemon-bpf kernel-patches-daemon-bpf bot deleted the series/1063861=>bpf branch March 10, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant