Skip to content

Commit 0252523

Browse files
listoutKernel Patches Daemon
authored andcommitted
bpf: Skip scalar adjustment for BPF_NEG if dst is a pointer
In check_alu_op(), the verifier currently calls check_reg_arg() and adjust_scalar_min_max_vals() unconditionally for BPF_NEG operations. However, if the destination register holds a pointer, these scalar adjustments are unnecessary and potentially incorrect. This patch adds a check to skip the adjustment logic when the destination register contains a pointer. Reported-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=d36d5ae81e1b0a53ef58 Fixes: aced132 ("bpf: Add range tracking for BPF_NEG") Suggested-by: KaFai Wan <[email protected]> Suggested-by: Eduard Zingerman <[email protected]> Signed-off-by: Brahmajit Das <[email protected]> Acked-by: Eduard Zingerman <[email protected]>
1 parent 5d00461 commit 0252523

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

kernel/bpf/verifier.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15645,7 +15645,8 @@ static int check_alu_op(struct bpf_verifier_env *env, struct bpf_insn *insn)
1564515645
}
1564615646

1564715647
/* check dest operand */
15648-
if (opcode == BPF_NEG) {
15648+
if (opcode == BPF_NEG &&
15649+
regs[insn->dst_reg].type == SCALAR_VALUE) {
1564915650
err = check_reg_arg(env, insn->dst_reg, DST_OP_NO_MARK);
1565015651
err = err ?: adjust_scalar_min_max_vals(env, insn,
1565115652
&regs[insn->dst_reg],

0 commit comments

Comments
 (0)