public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Andrii Nakryiko <andrii@kernel.org>,
	bpf@vger.kernel.org, ast@kernel.org,  daniel@iogearbox.net,
	martin.lau@kernel.org
Cc: kernel-team@meta.com
Subject: Re: [PATCH bpf-next 2/4] bpf: fix precision backtracking instruction iteration
Date: Thu, 09 Nov 2023 19:20:46 +0200	[thread overview]
Message-ID: <3ff0d703846a10d2a84ae5086511793a2aba5c08.camel@gmail.com> (raw)
In-Reply-To: <20231108231152.3583545-3-andrii@kernel.org>

On Wed, 2023-11-08 at 15:11 -0800, Andrii Nakryiko wrote:
> Fix an edge case in __mark_chain_precision() which prematurely stops
> backtracking instructions in a state if it happens that state's first
> and last instruction indexes are the same. This situations doesn't
> necessarily mean that there were no instructions simulated in a state,
> but rather that we starting from the instruction, jumped around a bit,
> and then ended up at the same instruction before checkpointing or
> marking precision.
> 
> To distinguish between these two possible situations, we need to consult
> jump history. If it's empty or contain a single record "bridging" parent
> state and first instruction of processed state, then we indeed
> backtracked all instructions in this state. But if history is not empty,
> we are definitely not done yet.
> 
> Move this logic inside get_prev_insn_idx() to contain it more nicely.
> Use -ENOENT return code to denote "we are out of instructions"
> situation.
>
> This bug was exposed by verifier_cfg.c's bounded_recursion subtest, once

Note: verifier_cfg.c should be verifier_loops1.c

> the next fix in this patch set is applied.
> 
> Fixes: b5dc0163d8fd ("bpf: precise scalar_value tracking")
> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>

Funny how nobody noticed this bug for so long, I looked at exactly
this code today while going through your other patch-set and no alarm
bells rang in my head.

I think that this case needs a dedicated test case that would check
precision tracking log.

Acked-by: Eduard Zingerman <eddyz87@gmail.com>

  reply	other threads:[~2023-11-09 17:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-08 23:11 [PATCH bpf-next 0/4] BPF control flow graph and precision backtrack fixes Andrii Nakryiko
2023-11-08 23:11 ` [PATCH bpf-next 1/4] bpf: handle ldimm64 properly in check_cfg() Andrii Nakryiko
2023-11-09 22:25   ` Eduard Zingerman
2023-11-08 23:11 ` [PATCH bpf-next 2/4] bpf: fix precision backtracking instruction iteration Andrii Nakryiko
2023-11-09 17:20   ` Eduard Zingerman [this message]
2023-11-09 23:18     ` Andrii Nakryiko
2023-11-09 23:28       ` Andrii Nakryiko
2023-11-09 23:37         ` Eduard Zingerman
2023-11-08 23:11 ` [PATCH bpf-next 3/4] bpf: fix control-flow graph checking in privileged mode Andrii Nakryiko
2023-11-09 22:00   ` Eduard Zingerman
2023-11-09 23:25     ` Andrii Nakryiko
2023-11-10  1:26   ` Alexei Starovoitov
2023-11-10  3:41     ` Andrii Nakryiko
2023-11-10  4:08       ` Alexei Starovoitov
2023-11-10  5:31         ` Andrii Nakryiko
2023-11-10  5:33           ` Andrii Nakryiko
2023-11-08 23:11 ` [PATCH bpf-next 4/4] selftests/bpf: add more test cases for check_cfg() Andrii Nakryiko
2023-11-09 22:21   ` Eduard Zingerman

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=3ff0d703846a10d2a84ae5086511793a2aba5c08.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@meta.com \
    --cc=martin.lau@kernel.org \
    /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