BPF List
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: bpf@vger.kernel.org
Cc: nathaniel.theis@nccgroup.com, ast@kernel.org, eddyz87@gmail.com,
	andrii@kernel.org, john.fastabend@gmail.com
Subject: [PATCH bpf 2/3] bpf: Fix print_reg_state's constant scalar dump
Date: Wed, 16 Oct 2024 15:49:12 +0200	[thread overview]
Message-ID: <20241016134913.32249-2-daniel@iogearbox.net> (raw)
In-Reply-To: <20241016134913.32249-1-daniel@iogearbox.net>

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>
---
 kernel/bpf/log.c | 3 +--
 1 file changed, 1 insertion(+), 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;
 	}
 
-- 
2.43.0


  reply	other threads:[~2024-10-16 13:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-16 13:49 [PATCH bpf 1/3] bpf: Fix incorrect delta propagation between linked registers Daniel Borkmann
2024-10-16 13:49 ` Daniel Borkmann [this message]
2024-10-16 20:16   ` [PATCH bpf 2/3] bpf: Fix print_reg_state's constant scalar dump Andrii Nakryiko
2024-10-16 13:49 ` [PATCH bpf 3/3] selftests/bpf: Add test case for delta propagation Daniel Borkmann
2024-10-16 21:56   ` Eduard Zingerman
2024-10-16 22:12 ` [PATCH bpf 1/3] bpf: Fix incorrect delta propagation between linked registers Eduard Zingerman
2024-10-17 18:10 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241016134913.32249-2-daniel@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=eddyz87@gmail.com \
    --cc=john.fastabend@gmail.com \
    --cc=nathaniel.theis@nccgroup.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox