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: <CAEf4BzYoRO3uSdtbWZzmbbgYc5ckSh9KRiOrnzT_JrSsWni30w@mail.gmail.com>
Date:   Sat, 5 Oct 2019 11:41:40 -0700
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Alexei Starovoitov <ast@...nel.org>
Cc:     "David S. Miller" <davem@...emloft.net>,
        Daniel Borkmann <daniel@...earbox.net>, x86@...nel.org,
        Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
        Kernel Team <kernel-team@...com>
Subject: Re: [PATCH bpf-next 02/10] bpf: add typecast to bpf helpers to help
 BTF generation

On Fri, Oct 4, 2019 at 10:05 PM Alexei Starovoitov <ast@...nel.org> wrote:
>
> When pahole converts dwarf to btf it emits only used types.
> Wrap existing bpf helper functions into typedef and use it in
> typecast to make gcc emits this type into dwarf.
> Then pahole will convert it to btf.
> The "btf_#name_of_helper" types will be used to figure out
> types of arguments of bpf helpers.
> The generate code before and after is the same.
> Only dwarf and btf are different.
>
> Signed-off-by: Alexei Starovoitov <ast@...nel.org>
> ---

It's amazing this works :)

Acked-by: Andrii Nakryiko <andriin@...com>

>  include/linux/filter.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/filter.h b/include/linux/filter.h
> index 2ce57645f3cd..d3d51d7aff2c 100644
> --- a/include/linux/filter.h
> +++ b/include/linux/filter.h
> @@ -464,10 +464,11 @@ static inline bool insn_is_zext(const struct bpf_insn *insn)
>  #define BPF_CALL_x(x, name, ...)                                              \
>         static __always_inline                                                 \
>         u64 ____##name(__BPF_MAP(x, __BPF_DECL_ARGS, __BPF_V, __VA_ARGS__));   \
> +       typedef u64 (*btf_##name)(__BPF_MAP(x, __BPF_DECL_ARGS, __BPF_V, __VA_ARGS__)); \
>         u64 name(__BPF_REG(x, __BPF_DECL_REGS, __BPF_N, __VA_ARGS__));         \
>         u64 name(__BPF_REG(x, __BPF_DECL_REGS, __BPF_N, __VA_ARGS__))          \
>         {                                                                      \
> -               return ____##name(__BPF_MAP(x,__BPF_CAST,__BPF_N,__VA_ARGS__));\
> +               return ((btf_##name)____##name)(__BPF_MAP(x,__BPF_CAST,__BPF_N,__VA_ARGS__));\
>         }                                                                      \
>         static __always_inline                                                 \
>         u64 ____##name(__BPF_MAP(x, __BPF_DECL_ARGS, __BPF_V, __VA_ARGS__))
> --
> 2.20.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ