bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zvi Effron <zeffron@riotgames.com>
To: Martin KaFai Lau <kafai@fb.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	Andrii Nakryiko <andrii.nakryiko@gmail.com>,
	Maciej Fijalkowski <maciej.fijalkowski@intel.com>,
	Cody Haas <chaas@riotgames.com>,
	Lisa Watanabe <lwatanabe@riotgames.com>
Subject: Re: [PATCH bpf-next v3 1/3] bpf: support input xdp_md context in BPF_PROG_TEST_RUN
Date: Fri, 4 Jun 2021 11:55:02 -0700	[thread overview]
Message-ID: <CAC1LvL1DBqConArA14dtK=G8Xt==fkMdY7H5KAoEyexQjgq8PQ@mail.gmail.com> (raw)
In-Reply-To: <20210603043421.3a4fsjbegcwy623f@kafai-mbp>

On Wed, Jun 2, 2021 at 9:34 PM Martin KaFai Lau <kafai@fb.com> wrote:
>
> On Wed, Jun 02, 2021 at 07:08:13PM +0000, Zvi Effron wrote:
> > +     data = xdp->data_meta + metalen;
> > +     if (data > xdp->data_end)
> This test and...
>
> > +             return -EINVAL;
> > +     xdp->data = data;
> > +
> > +     if (xdp_md->data_end - xdp_md->data != xdp->data_end - xdp->data)
> this one.  It is because the user input "xdp_md->data_end" does not
> match with kattr->test.data_size_in?  These tests are disconnected from
> where the actual invalid input is.  How about direclty testing
> xdp_md->data_end in bpf_prog_test_run_xdp() instead?
>

The first test is required because it's possible that the user provided value
for `xdp_md->data` could be greater than the user provided value for
`xdp_md->data_end`. For example, a user could pass a struct xdp_md that looked
like this:
```
struct xdp_md {
    .data_meta = 0,
    .data = 12,
    .data_end = 8,
};
```
We're moving the test and making it more clear what it's testing for in our
next patch version.

The second test can be eliminated by moving the test for xdp_md->data_end
against kattr->test.data_size_in as you suggest, which also allows simplifying
the surrounding code. We're updating that in our next patch version.

We're also addressing your other feedback in our next patch version.

  reply	other threads:[~2021-06-04 18:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02 19:08 [PATCH bpf-next v3 0/3] bpf: support input xdp_md context in BPF_PROG_TEST_RUN Zvi Effron
2021-06-02 19:08 ` [PATCH bpf-next v3 1/3] " Zvi Effron
2021-06-03  4:34   ` Martin KaFai Lau
2021-06-04 18:55     ` Zvi Effron [this message]
2021-06-02 19:08 ` [PATCH bpf-next v3 2/3] bpf: support specifying ingress via " Zvi Effron
2021-06-02 19:08 ` [PATCH bpf-next v3 3/3] selftests/bpf: Add test for " Zvi Effron

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='CAC1LvL1DBqConArA14dtK=G8Xt==fkMdY7H5KAoEyexQjgq8PQ@mail.gmail.com' \
    --to=zeffron@riotgames.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=chaas@riotgames.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=hawk@kernel.org \
    --cc=kafai@fb.com \
    --cc=lwatanabe@riotgames.com \
    --cc=maciej.fijalkowski@intel.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;
as well as URLs for NNTP newsgroup(s).