public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Yonghong Song <yonghong.song@linux.dev>
Cc: bpf@vger.kernel.org,  Alexei Starovoitov <ast@kernel.org>,
	 Andrii Nakryiko <andrii@kernel.org>,
	 Daniel Borkmann <daniel@iogearbox.net>,
	kernel-team@fb.com,  Martin KaFai Lau <martin.lau@kernel.org>
Subject: Re: [PATCH bpf-next v3 1/2] bpf: Do not include stack ptr register in precision backtracking bookkeeping
Date: Wed, 21 May 2025 13:58:20 -0700	[thread overview]
Message-ID: <m2ikltd6kz.fsf@gmail.com> (raw)
In-Reply-To: <2c0fa9ee-f9dd-4cde-b4fb-6f28ebefc619@linux.dev> (Yonghong Song's message of "Wed, 21 May 2025 13:34:50 -0700")

Yonghong Song <yonghong.song@linux.dev> writes:

[...]

>>> @@ -16397,6 +16423,29 @@ static void sync_linked_regs(struct
>>> bpf_verifier_state *vstate, struct bpf_reg_s
>>>       }
>>>   }
>>>   +static int push_cond_jmp_history(struct bpf_verifier_env *env,
>>> struct bpf_verifier_state *state,
>>> +                 struct bpf_reg_state *dst_reg, struct
>>> bpf_reg_state *src_reg,
>>> +                 u64 linked_regs)
>>> +{
>>> +    bool dreg_stack_ptr, sreg_stack_ptr;
>>> +    int insn_flags;
>>> +
>>> +    if (!src_reg) {
>>> +        if (linked_regs)
>>> +            return push_insn_history(env, state, 0, linked_regs);
>>> +        return 0;
>>> +    }
>>
>> Nit: this 'if' is not needed, src_reg is always set (it might point
>> to a fake register,
>>      but in that case it is a scalar without id).
>>
> Here, there is a bug here. Thanks for pointing this out. I need to check
> BPF_SRC(insn->code) != BPF_X instead of "!src_reg". Basically passing one
> more parameter (e.g., faked_sreg) to decide whether src_reg is faked or not.

I don't think any checks are needed.
Fake register is always scalar and it cannot be collected as a linked register.
So it won't end up in the instruction history flags.

[...]

  reply	other threads:[~2025-05-21 20:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-21 17:04 [PATCH bpf-next v3 1/2] bpf: Do not include stack ptr register in precision backtracking bookkeeping Yonghong Song
2025-05-21 17:04 ` [PATCH bpf-next v3 2/2] selftests/bpf: Add tests with stack ptr register in conditional jmp Yonghong Song
2025-05-21 19:02   ` Eduard Zingerman
2025-05-21 20:57     ` Yonghong Song
2025-05-21 21:03       ` Eduard Zingerman
2025-05-21 18:55 ` [PATCH bpf-next v3 1/2] bpf: Do not include stack ptr register in precision backtracking bookkeeping Eduard Zingerman
2025-05-21 20:34   ` Yonghong Song
2025-05-21 20:58     ` Eduard Zingerman [this message]
2025-05-21 21:35       ` Yonghong Song
2025-05-21 21:59         ` Eduard Zingerman
2025-05-21 22:04           ` Eduard Zingerman
2025-05-21 22:38     ` Andrii Nakryiko
2025-05-21 22:49       ` Eduard Zingerman
2025-05-22  2:53         ` Yonghong Song
2025-05-22 20:05         ` Andrii Nakryiko

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=m2ikltd6kz.fsf@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@fb.com \
    --cc=martin.lau@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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