public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Daniel Xu" <dxu@dxuuu.xyz>
To: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
Cc: "Shuah Khan" <shuah@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Eduard Zingerman" <eddyz87@gmail.com>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"Martin KaFai Lau" <martin.lau@linux.dev>,
	"Song Liu" <song@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>,
	"KP Singh" <kpsingh@kernel.org>,
	"Stanislav Fomichev" <sdf@fomichev.me>,
	"Hao Luo" <haoluo@google.com>, "Jiri Olsa" <jolsa@kernel.org>,
	"Mykola Lysenko" <mykolal@fb.com>,
	"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"open list:KERNEL SELFTEST FRAMEWORK"
	<linux-kselftest@vger.kernel.org>,
	"Kernel Team" <kernel-team@meta.com>
Subject: Re: [PATCH bpf-next v3 1/2] bpf: verifier: Support eliding map lookup nullness
Date: Tue, 01 Oct 2024 17:11:27 -0700	[thread overview]
Message-ID: <d0fb1d17-cd90-4ff1-9f8d-e671c99848b3@app.fastmail.com> (raw)
In-Reply-To: <haktyvoigwi2hz7f5j4m3go3trljy4u2cqis3wl7cl5iuhb4d7@nql73373o3ru>

Hit send too early.

On Tue, Oct 1, 2024, at 5:07 PM, Daniel Xu wrote:
> On Wed, Sep 25, 2024 at 10:24:01AM GMT, Alexei Starovoitov wrote:
>> On Tue, Sep 24, 2024 at 12:40 PM Daniel Xu <dxu@dxuuu.xyz> wrote:
>> >
>> > +
>> > +/* Returns constant key value if possible, else -1 */
>> > +static long get_constant_map_key(struct bpf_verifier_env *env,
>> > +                                struct bpf_reg_state *key)
>> > +{
>> > +       struct bpf_func_state *state = func(env, key);
>> > +       struct bpf_reg_state *reg;
>> > +       int stack_off;
>> > +       int slot;
>> > +       int spi;
>> > +
>> > +       if (key->type != PTR_TO_STACK)
>> > +               return -1;
>> > +       if (!tnum_is_const(key->var_off))
>> > +               return -1;
>> > +
>> > +       stack_off = key->off + key->var_off.value;
>> > +       slot = -stack_off - 1;
>> > +       if (slot < 0)
>> > +               /* Stack grew upwards */
>> 
>> The comment is misleading.
>> The verifier is supposed to catch this.
>> It's just this helper was called before the stack bounds
>> were checked?
>
> Yeah. Stack bounds checked in check_stack_access_within_bounds() as part
> of helper call argument checks.
>
>
>> Maybe the call can be done later?
>
> Maybe? The argument checking starts clobbering state so it'll probably
> be not very simple to pull information out after args are checked.
>
> I think the logic will probably be much easier to follow with current
> approach. But maybe I'm missing a simpler idea.

I can make the comment a bit more verbose. Maybe that's better than
trying to wire a bunch of logic through memory access checks.

  reply	other threads:[~2024-10-02  0:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-24 10:40 [PATCH bpf-next v3 0/2] Support eliding map lookup nullness Daniel Xu
2024-09-24 10:40 ` [PATCH bpf-next v3 1/2] bpf: verifier: " Daniel Xu
2024-09-24 18:44   ` Eduard Zingerman
2024-09-25  8:24   ` Alexei Starovoitov
2024-10-02  0:07     ` Daniel Xu
2024-10-02  0:11       ` Daniel Xu [this message]
2024-09-24 10:40 ` [PATCH bpf-next v3 2/2] bpf: selftests: verifier: Add nullness elision tests Daniel Xu

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=d0fb1d17-cd90-4ff1-9f8d-e671c99848b3@app.fastmail.com \
    --to=dxu@dxuuu.xyz \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mykolal@fb.com \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=song@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