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] [day] [month] [year] [list]
Date:   Fri, 4 Feb 2022 15:08:06 -0800
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Jiri Olsa <jolsa@...hat.com>
Cc:     Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>,
        Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
        Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...omium.org>,
        Toke Høiland-Jørgensen <toke@...hat.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Jiri Pirko <jiri@...lanox.com>
Subject: Re: [PATCH bpf-next 3/3] bpftool: Fix pretty print dump for maps
 without BTF loaded

On Fri, Feb 4, 2022 at 2:58 PM Jiri Olsa <jolsa@...hat.com> wrote:
>
> The commit e5043894b21f ("bpftool: Use libbpf_get_error() to check
> error") forced map dump with pretty print enabled to has BTF loaded,
> which is not necessarily needed.
>
> Keeping the libbpf_get_error call, but setting errno to 0 because
> get_map_kv_btf does nothing for this case.
>
> This fixes test_offload.py for me, which failed because of the
> pretty print fails with:
>
>    Test map dump...
>    Traceback (most recent call last):
>      File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 1251, in <module>
>        _, entries = bpftool("map dump id %d" % (m["id"]))
>      File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 169, in bpftool
>        return tool("bpftool", args, {"json":"-p"}, JSON=JSON, ns=ns,
>      File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 155, in tool
>        ret, stdout = cmd(ns + name + " " + params + args,
>      File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 109, in cmd
>        return cmd_result(proc, include_stderr=include_stderr, fail=fail)
>      File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 131, in cmd_result
>        raise Exception("Command failed: %s\n%s" % (proc.args, stderr))
>    Exception: Command failed: bpftool -p map dump id 4325
>
> Fixes: e5043894b21f ("bpftool: Use libbpf_get_error() to check error")
> Signed-off-by: Jiri Olsa <jolsa@...nel.org>
> ---
>  tools/bpf/bpftool/map.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
> index c66a3c979b7a..2ccf85042e75 100644
> --- a/tools/bpf/bpftool/map.c
> +++ b/tools/bpf/bpftool/map.c
> @@ -862,6 +862,7 @@ map_dump(int fd, struct bpf_map_info *info, json_writer_t *wtr,
>         prev_key = NULL;
>
>         if (wtr) {
> +               errno = 0;

I don't think that's right. errno can be modified by something inside
get_map_kv_btf() so this is unreliable approach. It's better to change
get_map_kv_btf() to return an error explicitly and a btf pointer
separate from error. Because btf == NULL isn't necessarily due to an
error anymore.

>                 btf = get_map_kv_btf(info);
>                 err = libbpf_get_error(btf);
>                 if (err) {
> --
> 2.34.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ