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  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:   Mon, 16 Mar 2020 17:01:35 -0700
From:   Stanislav Fomichev <sdf@...ichev.me>
To:     Nathan Chancellor <natechancellor@...il.com>
Cc:     Stanislav Fomichev <sdf@...gle.com>, netdev@...r.kernel.org,
        bpf@...r.kernel.org, davem@...emloft.net, ast@...nel.org,
        daniel@...earbox.net, Nick Desaulniers <ndesaulniers@...gle.com>
Subject: Re: [PATCH bpf] bpf: Support llvm-objcopy for vmlinux BTF

On 03/16, Nathan Chancellor wrote:
> On Mon, Mar 16, 2020 at 03:25:18PM -0700, Stanislav Fomichev wrote:
> > Commit da5fb18225b4 ("bpf: Support pre-2.25-binutils objcopy for vmlinux
> > BTF") switched from --dump-section to
> > --only-section/--change-section-address for BTF export assuming
> > those ("legacy") options should cover all objcopy versions.
> > 
> > Turns out llvm-objcopy doesn't implement --change-section-address [1],
> > but it does support --dump-section. Let's partially roll back and
> > try to use --dump-section first and fall back to
> > --only-section/--change-section-address for the older binutils.
> > 
> > 1. https://bugs.llvm.org/show_bug.cgi?id=45217
> > 
> > Fixes: df786c9b9476 ("bpf: Force .BTF section start to zero when dumping from vmlinux")
> > 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: Stanislav Fomichev <sdf@...gle.com>
> > ---
> >  scripts/link-vmlinux.sh | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> > 
> > diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
> > index dd484e92752e..8ddf57cbc439 100755
> > --- a/scripts/link-vmlinux.sh
> > +++ b/scripts/link-vmlinux.sh
> > @@ -127,6 +127,16 @@ gen_btf()
> >  		cut -d, -f1 | cut -d' ' -f2)
> >  	bin_format=$(LANG=C ${OBJDUMP} -f ${1} | grep 'file format' | \
> >  		awk '{print $4}')
> > +
> > +	# Compatibility issues:
> > +	# - pre-2.25 binutils objcopy doesn't support --dump-section
> > +	# - llvm-objcopy doesn't support --change-section-address, but
> > +	#   does support --dump-section
> > +	#
> > +	# Try to use --dump-section which should cover both recent
> > +	# binutils and llvm-objcopy and fall back to --only-section
> > +	# for pre-2.25 binutils.
> > +	${OBJCOPY} --dump-section .BTF=$bin_file ${1} 2>/dev/null || \
> >  	${OBJCOPY} --change-section-address .BTF=0 \
> >  		--set-section-flags .BTF=alloc -O binary \
> >  		--only-section=.BTF ${1} .btf.vmlinux.bin
> > -- 
> > 2.25.1.481.gfbce0eb801-goog
> > 
> 
> Hi Stanislav,
> 
> Thank you for the patch! This is targeting the bpf tree but it uses the
> bin_file variable that comes from commit af73d78bd384 ("kbuild: Remove
> debug info from kallsyms linking") in the bpf-next tree. In this form,
> when applied to mainline, the first command fails because $bin_file
> doesn't exist and falls back to the second command, which results in no
> net change for llvm-objcopy.
> 
> When manually applied to next-20200316 or applied to mainline with
> $bin_file replaced with .btf.vmlinux.bin, x86_64 and aarch64 successfully
>  generate BTF with tip of tree llvm-objcopy.
> 
> Tested-by: Nathan Chancellor <natechancellor@...il.com>
Oops, sorry, I did it on top of bpf-next, but then blindly cherry-picked
on top of bpf tree. In this case, should we put in only in bpf-next?
Do we need a stable backport for the older versions?

Powered by blists - more mailing lists