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: <CAPhsuW5ZHQao4Af-M3C8ZmfWxFG3m+NTONQs3rk_sSk61jUGug@mail.gmail.com>
Date:   Mon, 8 Oct 2018 23:57:38 -0700
From:   Song Liu <liu.song.a23@...il.com>
To:     Prashant Bhole <bhole_prashant_q7@....ntt.co.jp>
Cc:     Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Jakub Kicinski <jakub.kicinski@...ronome.com>,
        "David S . Miller" <davem@...emloft.net>,
        Quentin Monnet <quentin.monnet@...ronome.com>,
        Networking <netdev@...r.kernel.org>
Subject: Re: [PATCH bpf-next 1/6] bpf: error handling when map_lookup_elem
 isn't supported

On Mon, Oct 8, 2018 at 6:06 PM Prashant Bhole
<bhole_prashant_q7@....ntt.co.jp> wrote:
>
> The error value returned by map_lookup_elem doesn't differentiate
> whether lookup was failed because of invalid key or lookup is not
> supported.
>
> Lets add handling for -EOPNOTSUPP return value of map_lookup_elem()
> method of map, with expectation from map's implementation that it
> should return -EOPNOTSUPP if lookup is not supported.
>
> The errno for bpf syscall for BPF_MAP_LOOKUP_ELEM command will be set
> to EOPNOTSUPP if map lookup is not supported.
>
> Signed-off-by: Prashant Bhole <bhole_prashant_q7@....ntt.co.jp>
> Acked-by: Alexei Starovoitov <ast@...nel.org>

Acked-by: Song Liu <songliubraving@...com>

> ---
>  kernel/bpf/syscall.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 5742df21598c..4f416234251f 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -719,10 +719,15 @@ static int map_lookup_elem(union bpf_attr *attr)
>         } else {
>                 rcu_read_lock();
>                 ptr = map->ops->map_lookup_elem(map, key);
> -               if (ptr)
> +               if (IS_ERR(ptr)) {
> +                       err = PTR_ERR(ptr);
> +               } else if (!ptr) {
> +                       err = -ENOENT;
> +               } else {
> +                       err = 0;
>                         memcpy(value, ptr, value_size);
> +               }
>                 rcu_read_unlock();
> -               err = ptr ? 0 : -ENOENT;
>         }
>
>         if (err)
> --
> 2.17.1
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ