Skip to content

Commit 3e9e708

Browse files
borkmannanakryiko
authored andcommitted
bpf: Fix print_reg_state's constant scalar dump
print_reg_state() should not consider adding reg->off to reg->var_off.value when dumping scalars. Scalars can be produced with reg->off != 0 through BPF_ADD_CONST, and thus as-is this can skew the register log dump. Fixes: 98d7ca3 ("bpf: Track delta between "linked" registers.") Reported-by: Nathaniel Theis <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 3878ae0 commit 3e9e708

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

kernel/bpf/log.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,7 @@ static void print_reg_state(struct bpf_verifier_env *env,
688688
if (t == SCALAR_VALUE && reg->precise)
689689
verbose(env, "P");
690690
if (t == SCALAR_VALUE && tnum_is_const(reg->var_off)) {
691-
/* reg->off should be 0 for SCALAR_VALUE */
692-
verbose_snum(env, reg->var_off.value + reg->off);
691+
verbose_snum(env, reg->var_off.value);
693692
return;
694693
}
695694

0 commit comments

Comments
 (0)