lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 30 Jun 2022 11:57:37 +0200
From:   Magnus Karlsson <magnus.karlsson@...il.com>
To:     Maciej Fijalkowski <maciej.fijalkowski@...el.com>
Cc:     bpf <bpf@...r.kernel.org>, Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>,
        Network Development <netdev@...r.kernel.org>,
        "Karlsson, Magnus" <magnus.karlsson@...el.com>
Subject: Re: [PATCH bpf-next 3/4] selftests: xsk: verify correctness of XDP
 prog attach point

On Wed, Jun 29, 2022 at 4:39 PM Maciej Fijalkowski
<maciej.fijalkowski@...el.com> wrote:
>
> To prevent the case we had previously where for TEST_MODE_SKB, XDP prog
> was attached in native mode, call bpf_xdp_query() after loading prog and
> make sure that attach_mode is as expected.

Acked-by: Magnus Karlsson <magnus.karlsson@...el.com>

> Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@...el.com>
> ---
>  tools/testing/selftests/bpf/xdpxceiver.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/xdpxceiver.c b/tools/testing/selftests/bpf/xdpxceiver.c
> index c024aa91ea02..4c425a43e5b0 100644
> --- a/tools/testing/selftests/bpf/xdpxceiver.c
> +++ b/tools/testing/selftests/bpf/xdpxceiver.c
> @@ -1085,6 +1085,7 @@ static void thread_common_ops(struct test_spec *test, struct ifobject *ifobject)
>  {
>         u64 umem_sz = ifobject->umem->num_frames * ifobject->umem->frame_size;
>         int mmap_flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE;
> +       LIBBPF_OPTS(bpf_xdp_query_opts, opts);
>         int ret, ifindex;
>         void *bufs;
>         u32 i;
> @@ -1134,6 +1135,22 @@ static void thread_common_ops(struct test_spec *test, struct ifobject *ifobject)
>         if (ret)
>                 exit_with_error(-ret);
>
> +       ret = bpf_xdp_query(ifindex, ifobject->xdp_flags, &opts);
> +       if (ret)
> +               exit_with_error(-ret);
> +
> +       if (ifobject->xdp_flags & XDP_FLAGS_SKB_MODE) {
> +               if (opts.attach_mode != XDP_ATTACHED_SKB) {
> +                       ksft_print_msg("ERROR: [%s] XDP prog not in SKB mode\n");
> +                       exit_with_error(-EINVAL);
> +               }
> +       } else if (ifobject->xdp_flags & XDP_FLAGS_DRV_MODE) {
> +               if (opts.attach_mode != XDP_ATTACHED_DRV) {
> +                       ksft_print_msg("ERROR: [%s] XDP prog not in DRV mode\n");
> +                       exit_with_error(-EINVAL);
> +               }
> +       }
> +
>         ret = xsk_socket__update_xskmap(ifobject->xsk->xsk, ifobject->xsk_map_fd);
>         if (ret)
>                 exit_with_error(-ret);
> --
> 2.27.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ