Skip to content

Commit 4a2ff55

Browse files
borkmanndavem330
authored andcommitted
bpf: reset id on CONST_IMM transition
Whenever we set the register to the type CONST_IMM, we currently don't reset the id to 0. id member is not used in CONST_IMM case, so don't let it become stale, where pruning won't be able to match later on. Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Alexei Starovoitov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d25da6c commit 4a2ff55

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

kernel/bpf/verifier.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,6 +1952,7 @@ static int check_alu_op(struct bpf_verifier_env *env, struct bpf_insn *insn)
19521952
*/
19531953
regs[insn->dst_reg].type = CONST_IMM;
19541954
regs[insn->dst_reg].imm = insn->imm;
1955+
regs[insn->dst_reg].id = 0;
19551956
regs[insn->dst_reg].max_value = insn->imm;
19561957
regs[insn->dst_reg].min_value = insn->imm;
19571958
regs[insn->dst_reg].min_align = calc_align(insn->imm);
@@ -2409,6 +2410,7 @@ static int check_ld_imm(struct bpf_verifier_env *env, struct bpf_insn *insn)
24092410

24102411
regs[insn->dst_reg].type = CONST_IMM;
24112412
regs[insn->dst_reg].imm = imm;
2413+
regs[insn->dst_reg].id = 0;
24122414
return 0;
24132415
}
24142416

0 commit comments

Comments
 (0)