Re: [PATCH bpf-next v3 1/3] bpf: support input xdp_md context in BPF_PROG_TEST_RUN

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 2, 2021 at 9:34 PM Martin KaFai Lau <kafai@xxxxxx> 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.



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux