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:   Wed, 30 Sep 2020 10:34:05 +0800
From:   Hangbin Liu <liuhangbin@...il.com>
To:     Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc:     bpf <bpf@...r.kernel.org>, Networking <netdev@...r.kernel.org>,
        Toke Høiland-Jørgensen <toke@...hat.com>,
        Jiri Benc <jbenc@...hat.com>,
        Jesper Dangaard Brouer <brouer@...hat.com>,
        Daniel Borkmann <daniel@...earbox.net>,
        Alexei Starovoitov <ast@...nel.org>,
        Stephen Hemminger <stephen@...workplumber.org>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>
Subject: Re: [PATCH bpf-next] libbpf: export bpf_object__reuse_map() to
 libbpf api

On Tue, Sep 29, 2020 at 04:03:45PM -0700, Andrii Nakryiko wrote:
> > bpf_map__set_pin_path()
> > bpf_create_map_in_map()    <- create inner or outer map
> > bpf_map__reuse_fd(map, inner/outer_fd)
> > bpf_object__load(obj)
> >   - bpf_object__load_xattr()
> >     - bpf_object__create_maps()
> >       - if (map->fd >= 0)
> >           continue      <- this will skip pinning map
> 
> so maybe that's the part that needs to be fixed?..

Hmm...maybe, let me see

> 
> I'm still not sure. And to be honest your examples are still a bit too
> succinct for me to follow where the problem is exactly. Can you please
> elaborate a bit more?

Let's take iproute2 legacy map for example, if it's a map-in-map type with
pin path defined. In user space we could do like:

if (bpf_obj_get(pathname) < 0) {
	bpf_create_map_in_map();
	bpf_map__reuse_fd(map, map_fd);
}
bpf_map__set_pin_path(map, pathname);
bpf_object__load(obj)

So in libbpf we need

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 32dc444224d8..5412aa7169db 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -4215,7 +4215,7 @@ bpf_object__create_maps(struct bpf_object *obj)
                if (map->fd >= 0) {
                        pr_debug("map '%s': skipping creation (preset fd=%d)\n",
                                 map->name, map->fd);
-                       continue;
+                       goto check_pin_path;
                }

                err = bpf_object__create_map(obj, map);
@@ -4258,6 +4258,7 @@ bpf_object__create_maps(struct bpf_object *obj)
                        map->init_slots_sz = 0;
                }

+check_pin_path:
                if (map->pin_path && !map->pinned) {
                        err = bpf_map__pin(map, NULL);
                        if (err) {


Do you think if this change be better?

Thanks
Hangbin

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ