summaryrefslogtreecommitdiffstats
path: root/kernel/bpf/log.c
diff options
context:
space:
mode:
authorDaniel Borkmann <daniel@iogearbox.net>2024-10-16 15:49:12 +0200
committerAndrii Nakryiko <andrii@kernel.org>2024-10-17 20:06:34 +0200
commit3e9e708757ca3b7eb65a820031d62fea1a265709 (patch)
treed430bbb3ef23b6f94cb6f0e7574c89fb2c93cc7f /kernel/bpf/log.c
parentbpf: Fix incorrect delta propagation between linked registers (diff)
downloadlinux-3e9e708757ca3b7eb65a820031d62fea1a265709.tar.xz
linux-3e9e708757ca3b7eb65a820031d62fea1a265709.zip
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: 98d7ca374ba4 ("bpf: Track delta between "linked" registers.") Reported-by: Nathaniel Theis <nathaniel.theis@nccgroup.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20241016134913.32249-2-daniel@iogearbox.net
Diffstat (limited to 'kernel/bpf/log.c')
-rw-r--r--kernel/bpf/log.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/kernel/bpf/log.c b/kernel/bpf/log.c
index 5aebfc3051e3..4a858fdb6476 100644
--- a/kernel/bpf/log.c
+++ b/kernel/bpf/log.c
@@ -688,8 +688,7 @@ static void print_reg_state(struct bpf_verifier_env *env,
if (t == SCALAR_VALUE && reg->precise)
verbose(env, "P");
if (t == SCALAR_VALUE && tnum_is_const(reg->var_off)) {
- /* reg->off should be 0 for SCALAR_VALUE */
- verbose_snum(env, reg->var_off.value + reg->off);
+ verbose_snum(env, reg->var_off.value);
return;
}