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: <CAEf4BzYyimAo2_513kW6hrDWwmzSDhNjTYksjy01ugKKTPt+qA@mail.gmail.com>
Date:   Mon, 16 Mar 2020 22:09:12 -0700
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Fangrui Song <maskray@...gle.com>
Cc:     bpf <bpf@...r.kernel.org>, Networking <netdev@...r.kernel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        Nathan Chancellor <natechancellor@...il.com>,
        clang-built-linux@...glegroups.com,
        Stanislav Fomichev <sdf@...gle.com>,
        "David S. Miller" <davem@...emloft.net>,
        Alexei Starovoitov <ast@...nel.org>
Subject: Re: [PATCH bpf v2] bpf: Support llvm-objcopy and llvm-objdump for
 vmlinux BTF

On Mon, Mar 16, 2020 at 8:37 PM Fangrui Song <maskray@...gle.com> wrote:
>
> On 2020-03-16, Andrii Nakryiko wrote:
> >On Mon, Mar 16, 2020 at 6:17 PM Fangrui Song <maskray@...gle.com> wrote:
> >>
> >> Simplify gen_btf logic to make it work with llvm-objcopy and
> >> llvm-objdump.  We just need to retain one section .BTF. To do so, we can
> >> use a simple objcopy --only-section=.BTF instead of jumping all the
> >> hoops via an architecture-less binary file.
> >>
> >> We use a dd comment to change the e_type field in the ELF header from
> >> ET_EXEC to ET_REL so that .btf.vmlinux.bin.o will be accepted by lld.
> >>
> >> Fixes: df786c9b9476 ("bpf: Force .BTF section start to zero when dumping from vmlinux")
> >> Cc: Stanislav Fomichev <sdf@...gle.com>
> >> Cc: Nick Desaulniers <ndesaulniers@...gle.com>
> >> Tested-by: Nick Desaulniers <ndesaulniers@...gle.com>
> >> Reported-by: Nathan Chancellor <natechancellor@...il.com>
> >> Link: https://github.com/ClangBuiltLinux/linux/issues/871
> >> Signed-off-by: Fangrui Song <maskray@...gle.com>
> >> ---
> >>  scripts/link-vmlinux.sh | 13 ++-----------
> >>  1 file changed, 2 insertions(+), 11 deletions(-)
> >>
> >> diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
> >> index dd484e92752e..84be8d7c361d 100755
> >> --- a/scripts/link-vmlinux.sh
> >> +++ b/scripts/link-vmlinux.sh
> >> @@ -120,18 +120,9 @@ gen_btf()
> >>
> >>         info "BTF" ${2}
> >>         vmlinux_link ${1}
> >> -       LLVM_OBJCOPY=${OBJCOPY} ${PAHOLE} -J ${1}
> >
> >Is it really tested? Seems like you just dropped .BTF generation step
> >completely...
>
> Sorry, dropped the whole line:/
> I don't know how to test .BTF . I can only check readelf -S...
>
> Attached the new patch.
>
>
>  From 02afb9417d4f0f8d2175c94fc3797a94a95cc248 Mon Sep 17 00:00:00 2001
> From: Fangrui Song <maskray@...gle.com>
> Date: Mon, 16 Mar 2020 18:02:31 -0700
> Subject: [PATCH bpf v2] bpf: Support llvm-objcopy and llvm-objdump for
>   vmlinux BTF
>
> Simplify gen_btf logic to make it work with llvm-objcopy and llvm-objdump.
> We use a dd comment to change the e_type field in the ELF header from
> ET_EXEC to ET_REL so that .btf.vmlinux.bin.o can be accepted by lld.
>
> Fixes: df786c9b9476 ("bpf: Force .BTF section start to zero when dumping from vmlinux")
> Cc: Stanislav Fomichev <sdf@...gle.com>
> Cc: Nick Desaulniers <ndesaulniers@...gle.com>
> Reported-by: Nathan Chancellor <natechancellor@...il.com>
> Link: https://github.com/ClangBuiltLinux/linux/issues/871
> Signed-off-by: Fangrui Song <maskray@...gle.com>
> ---
>   scripts/link-vmlinux.sh | 14 +++-----------
>   1 file changed, 3 insertions(+), 11 deletions(-)
>
> diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
> index dd484e92752e..b23313944c89 100755
> --- a/scripts/link-vmlinux.sh
> +++ b/scripts/link-vmlinux.sh
> @@ -120,18 +120,10 @@ gen_btf()
>
>         info "BTF" ${2}
>         vmlinux_link ${1}
> -       LLVM_OBJCOPY=${OBJCOPY} ${PAHOLE} -J ${1}
> +       ${PAHOLE} -J ${1}

I'm not sure why you are touching this line at all. LLVM_OBJCOPY part
is necessary, pahole assumes llvm-objcopy by default, but that can
(and should for objcopy) be overridden with LLVM_OBJCOPY.

>
> -       # dump .BTF section into raw binary file to link with final vmlinux
> -       bin_arch=$(LANG=C ${OBJDUMP} -f ${1} | grep architecture | \
> -               cut -d, -f1 | cut -d' ' -f2)
> -       bin_format=$(LANG=C ${OBJDUMP} -f ${1} | grep 'file format' | \
> -               awk '{print $4}')
> -       ${OBJCOPY} --change-section-address .BTF=0 \
> -               --set-section-flags .BTF=alloc -O binary \
> -               --only-section=.BTF ${1} .btf.vmlinux.bin
> -       ${OBJCOPY} -I binary -O ${bin_format} -B ${bin_arch} \
> -               --rename-section .data=.BTF .btf.vmlinux.bin ${2}
> +       # Extract .BTF section, change e_type to ET_REL, to link with final vmlinux
> +       ${OBJCOPY} --only-section=.BTF ${1} ${2} && printf '\1' | dd of=${2} conv=notrunc bs=1 seek=16
>   }
>
>   # Create ${2} .o file with all symbols from the ${1} object file
> --
> 2.25.1.481.gfbce0eb801-goog
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ