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]
Message-ID: <CAPhsuW4hYuUMms1Jv9gfz0QV06y6Qvna1xdjL5fFdgTQz_e9iw@mail.gmail.com>
Date:   Mon, 17 Oct 2022 09:27:57 -0700
From:   Song Liu <song@...nel.org>
To:     Gerhard Engleder <gerhard@...leder-embedded.com>
Cc:     ast@...nel.org, daniel@...earbox.net, davem@...emloft.net,
        kuba@...nel.org, hawk@...nel.org, john.fastabend@...il.com,
        bpf@...r.kernel.org, netdev@...r.kernel.org
Subject: Re: [PATCH net-next] samples/bpf: Fix map interation in xdp1_user

On Thu, Oct 13, 2022 at 2:01 PM Gerhard Engleder
<gerhard@...leder-embedded.com> wrote:
>
> BPF map iteration in xdp1_user results in endless loop without any
> output, because the return value of bpf_map_get_next_key() is checked
> against the wrong value.
>
> Other call locations of bpf_map_get_next_key() check for equal 0 for
> continuing the iteration. xdp1_user checks against unequal -1. This is
> wrong for a function which can return arbitrary negative errno values,
> because a return value of e.g. -2 results in an endless loop.
>
> With this fix xdp1_user is printing statistics again:
> proto 0:          1 pkt/s
> proto 0:          1 pkt/s
> proto 17:     107383 pkt/s
> proto 17:     881655 pkt/s
> proto 17:     882083 pkt/s
> proto 17:     881758 pkt/s
>
> Signed-off-by: Gerhard Engleder <gerhard@...leder-embedded.com>

Acked-by: Song Liu <song@...nel.org>

> ---
>  samples/bpf/xdp1_user.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/samples/bpf/xdp1_user.c b/samples/bpf/xdp1_user.c
> index ac370e638fa3..281dc964de8d 100644
> --- a/samples/bpf/xdp1_user.c
> +++ b/samples/bpf/xdp1_user.c
> @@ -51,7 +51,7 @@ static void poll_stats(int map_fd, int interval)
>
>                 sleep(interval);
>
> -               while (bpf_map_get_next_key(map_fd, &key, &key) != -1) {
> +               while (bpf_map_get_next_key(map_fd, &key, &key) == 0) {
>                         __u64 sum = 0;
>
>                         assert(bpf_map_lookup_elem(map_fd, &key, values) == 0);
> --
> 2.30.2
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ