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: <CAEf4Bzb6cGC_UcH+-WfZaj1i7nnZApTGp3wb0g11HehcURtm9A@mail.gmail.com>
Date:   Fri, 8 Nov 2019 11:34:59 -0800
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Song Liu <songliubraving@...com>
Cc:     Andrii Nakryiko <andriin@...com>, bpf <bpf@...r.kernel.org>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        Alexei Starovoitov <ast@...com>,
        "daniel@...earbox.net" <daniel@...earbox.net>,
        Kernel Team <Kernel-team@...com>
Subject: Re: [PATCH bpf-next 2/3] libbpf: make global data internal arrays
 mmap()-able, if possible

On Thu, Nov 7, 2019 at 10:44 PM Song Liu <songliubraving@...com> wrote:
>
>
>
> > On Nov 7, 2019, at 8:20 PM, Andrii Nakryiko <andriin@...com> wrote:
> >
> > Add detection of BPF_F_MMAPABLE flag support for arrays and add it as an extra
> > flag to internal global data maps, if supported by kernel. This allows users
> > to memory-map global data and use it without BPF map operations, greatly
> > simplifying user experience.
> >
> > Signed-off-by: Andrii Nakryiko <andriin@...com>
>
> Acked-by: Song Liu <songliubraving@...com>
>
> With nit below.
>
> > ---
> > tools/lib/bpf/libbpf.c | 31 +++++++++++++++++++++++++++++--
> > 1 file changed, 29 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> > index fde6cb3e5d41..73607a31a068 100644
> > --- a/tools/lib/bpf/libbpf.c
> > +++ b/tools/lib/bpf/libbpf.c
> > @@ -142,6 +142,8 @@ struct bpf_capabilities {
> >       __u32 btf_func:1;
> >       /* BTF_KIND_VAR and BTF_KIND_DATASEC support */
> >       __u32 btf_datasec:1;
> > +     /* BPF_F_MMAPABLE is supported for arrays */
> > +     __u32 array_mmap:1;
> > };
> >
> > /*
> > @@ -855,8 +857,6 @@ bpf_object__init_internal_map(struct bpf_object *obj, enum libbpf_map_type type,
> >               pr_warn("failed to alloc map name\n");
> >               return -ENOMEM;
> >       }
> > -     pr_debug("map '%s' (global data): at sec_idx %d, offset %zu.\n",
> > -              map_name, map->sec_idx, map->sec_offset);
> >
> >       def = &map->def;
> >       def->type = BPF_MAP_TYPE_ARRAY;
> > @@ -864,6 +864,12 @@ bpf_object__init_internal_map(struct bpf_object *obj, enum libbpf_map_type type,
> >       def->value_size = data->d_size;
> >       def->max_entries = 1;
> >       def->map_flags = type == LIBBPF_MAP_RODATA ? BPF_F_RDONLY_PROG : 0;
> > +     if (obj->caps.array_mmap)
> > +             def->map_flags |= BPF_F_MMAPABLE;
> > +
> > +     pr_debug("map '%s' (global data): at sec_idx %d, offset %zu, flags %u.\n",
>
> nit: Better print flags as %x.
>
>

sure, will update

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ