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: <CAPhsuW6WgjL_atKCivbk5iMNBFHuSGcjAC0tdZYag2fOesUBKA@mail.gmail.com>
Date:   Tue, 22 Feb 2022 18:36:57 -0800
From:   Song Liu <song@...nel.org>
To:     Stijn Tintel <stijn@...ux-ipv6.be>
Cc:     Toke Høiland-Jørgensen <toke@...hat.com>,
        Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
        open list <linux-kernel@...r.kernel.org>,
        KP Singh <kpsingh@...nel.org>,
        John Fastabend <john.fastabend@...il.com>,
        Yonghong Song <yhs@...com>, Song Liu <songliubraving@...com>,
        Martin KaFai Lau <kafai@...com>,
        Andrii Nakryiko <andrii@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Alexei Starovoitov <ast@...nel.org>
Subject: Re: [PATCH] libbpf: fix BPF_MAP_TYPE_PERF_EVENT_ARRAY auto-pinning

On Tue, Feb 22, 2022 at 12:51 PM Stijn Tintel <stijn@...ux-ipv6.be> wrote:
>
> When a BPF map of type BPF_MAP_TYPE_PERF_EVENT_ARRAY doesn't have the
> max_entries parameter set, this parameter will be set to the number of
> possible CPUs. Due to this, the map_is_reuse_compat function will return
> false, causing the following error when trying to reuse the map:
>
> libbpf: couldn't reuse pinned map at '/sys/fs/bpf/m_logging': parameter mismatch
>
> Fix this by checking against the number of possible CPUs if the
> max_entries parameter is not set in the map definition.
>
> Fixes: 57a00f41644f ("libbpf: Add auto-pinning of maps when loading BPF objects")
> Signed-off-by: Stijn Tintel <stijn@...ux-ipv6.be>

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

I think the following fix would be more future proof, but the patch
as-is is better for
stable backport? How about we add a follow up patch on top of current
patch to fix
def->max_entries once for all?

Thanks,
Song

diff --git i/tools/lib/bpf/libbpf.c w/tools/lib/bpf/libbpf.c
index ad43b6ce825e..a1bc1c80bc69 100644
--- i/tools/lib/bpf/libbpf.c
+++ w/tools/lib/bpf/libbpf.c
@@ -4881,10 +4881,9 @@ static int bpf_object__create_map(struct
bpf_object *obj, struct bpf_map *map, b
                        return nr_cpus;
                }
                pr_debug("map '%s': setting size to %d\n", map->name, nr_cpus);
-               max_entries = nr_cpus;
-       } else {
-               max_entries = def->max_entries;
+               def->max_entries = nr_cpus;
        }
+       max_entries = def->max_entries;

        if (bpf_map__is_struct_ops(map))
                create_attr.btf_vmlinux_value_type_id =
map->btf_vmlinux_value_type_id;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ