summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@kernel.org>2025-10-01 13:53:20 -0700
committerAlexei Starovoitov <ast@kernel.org>2025-10-01 13:55:08 -0700
commita1aca22d264cdca5b20934a2413951ea7d73c594 (patch)
tree761496156250d09e0e9d9294da0b21752c461878 /kernel
parent0c342bfc9949dffeaa83ebdde3b4b0ce59009348 (diff)
parent8709c1685220e766d4d9420f96b1e8ed3175f526 (diff)
Merge branch 'bpf-fix-verifier-crash-on-bpf_neg-with-pointer-register'
Brahmajit Das says: ==================== bpf: Fix verifier crash on BPF_NEG with pointer register This patch fixes a crash in the BPF verifier triggered when the BPF_NEG operation is applied to a pointer-typed register. The verifier now checks that the destination register is not a pointer before performing the operation. Tested with syzkaller reproducer and new BPF sefltest. Closes: https://syzkaller.appspot.com/bug?extid=d36d5ae81e1b0a53ef58 Changes v4: Cleaning up, instead of using __is_pointer_value it's further simplified by checking if regs[insn->dst_reg].type of SCALAR_VALUE Link: Changes in v3: using __is_pointer_value to check if register if of pointer type Link: https://lore.kernel.org/all/20251001095613.267475-1-listout@listout.xyz/ Changes in v2: Checking if reg->map_ptr is NULL in bpf/log.c but with cleaner approach (wrong approach) Link: https://lore.kernel.org/all/20250923174738.1713751-1-listout@listout.xyz/ Changes in v1: Checking if reg->map_ptr is NULL in bpf/log.c (wrong approach) Link: https://lore.kernel.org/all/20250923164144.1573636-1-listout@listout.xyz/ ==================== Link: https://patch.msgid.link/20251001191739.2323644-1-listout@listout.xyz Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/bpf/verifier.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 73bba397672a..a5c52d53502a 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -15645,7 +15645,8 @@ static int check_alu_op(struct bpf_verifier_env *env, struct bpf_insn *insn)
}
/* check dest operand */
- if (opcode == BPF_NEG) {
+ if (opcode == BPF_NEG &&
+ regs[insn->dst_reg].type == SCALAR_VALUE) {
err = check_reg_arg(env, insn->dst_reg, DST_OP_NO_MARK);
err = err ?: adjust_scalar_min_max_vals(env, insn,
&regs[insn->dst_reg],