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, 16 Feb 2022 10:20:37 -0800
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Mauricio Vásquez <mauricio@...volk.io>
Cc:     Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>,
        Quentin Monnet <quentin@...valent.com>,
        Rafael David Tinoco <rafaeldtinoco@...il.com>,
        Lorenzo Fontana <lorenzo.fontana@...stic.co>,
        Leonardo Di Donato <leonardo.didonato@...stic.co>
Subject: Re: [PATCH bpf-next v7 5/7] bpftool: Implement btfgen_get_btf()

On Tue, Feb 15, 2022 at 2:59 PM Mauricio Vásquez <mauricio@...volk.io> wrote:
>
> The last part of the BTFGen algorithm is to create a new BTF object with
> all the types that were recorded in the previous steps.
>
> This function performs two different steps:
> 1. Add the types to the new BTF object by using btf__add_type(). Some
> special logic around struct and unions is implemented to only add the
> members that are really used in the field-based relocations. The type
> ID on the new and old BTF objects is stored on a map.
> 2. Fix all the type IDs on the new BTF object by using the IDs saved in
> the previous step.
>
> Signed-off-by: Mauricio Vásquez <mauricio@...volk.io>
> Signed-off-by: Rafael David Tinoco <rafael.tinoco@...asec.com>
> Signed-off-by: Lorenzo Fontana <lorenzo.fontana@...stic.co>
> Signed-off-by: Leonardo Di Donato <leonardo.didonato@...stic.co>
> ---
>  tools/bpf/bpftool/gen.c | 100 +++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 99 insertions(+), 1 deletion(-)
>

[...]

> +                       cloned_m = btf_members(cloned_type);
> +                       m = btf_members(type);
> +                       vlen = btf_vlen(cloned_type);
> +                       for (idx_src = 0; idx_src < vlen; idx_src++, cloned_m++, m++) {
> +                               /* add only members that are marked as used */
> +                               if (cloned_m->name_off != MARKED)
> +                                       continue;
> +
> +                               name = btf__str_by_offset(info->src_btf, m->name_off);
> +                               err = btf__add_field(btf_new, name, m->type,
> +                                                    BTF_MEMBER_BIT_OFFSET(m->offset),
> +                                                    BTF_MEMBER_BITFIELD_SIZE(m->offset));

BTF_MEMBER_BIT_OFFSET() and BTF_MEMBER_BIT_OFFSET() shouldn't be used
unconditionally, only if kflag is set. It's better to use
btf_member_bit_offset() and btf_member_bitfield_size() helpers here,
they handle this transparently.

> +                               if (err < 0)
> +                                       goto err_out;
> +                       }
> +               } else {
> +                       err = btf__add_type(btf_new, info->src_btf, type);
> +                       if (err < 0)
> +                               goto err_out;
> +                       new_id = err;
> +               }
> +
> +               /* add ID mapping */
> +               ids[i] = new_id;
> +       }
> +

[...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ