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] [day] [month] [year] [list]
Message-ID: <a727a688-2555-b7e3-ab29-43f46a3c3e52@iogearbox.net>
Date:   Fri, 29 Nov 2019 16:16:36 +0100
From:   Daniel Borkmann <daniel@...earbox.net>
To:     John Fastabend <john.fastabend@...il.com>,
        Stanislav Fomichev <sdf@...gle.com>, netdev@...r.kernel.org,
        bpf@...r.kernel.org
Cc:     davem@...emloft.net, ast@...nel.org,
        Andrii Nakryiko <andriin@...com>
Subject: Re: [PATCH bpf] bpf: force .BTF section start to zero when dumping
 from vmlinux

On 11/28/19 5:37 AM, John Fastabend wrote:
> Stanislav Fomichev wrote:
>> While trying to figure out why fentry_fexit selftest doesn't pass for me
>> (old pahole, broken BTF), I found out that my latest patch can break vmlinux
>> .BTF generation. objcopy preserves section start when doing --only-section,
>> so there is a chance (depending on where pahole inserts .BTF section) to
>> have leading empty zeroes. Let's explicitly force section offset to zero.
>>
>> Before:
>> $ objcopy --set-section-flags .BTF=alloc -O binary \
>> 	--only-section=.BTF vmlinux .btf.vmlinux.bin
>> $ xxd .btf.vmlinux.bin | head -n1
>> 00000000: 0000 0000 0000 0000 0000 0000 0000 0000  ................
>>
>> After:
>> $ objcopy --change-section-address .BTF=0 \
>> 	--set-section-flags .BTF=alloc -O binary \
>> 	--only-section=.BTF vmlinux .btf.vmlinux.bin
>> $ xxd .btf.vmlinux.bin | head -n1
>> 00000000: 9feb 0100 1800 0000 0000 0000 80e1 1c00  ................
>>            ^BTF magic
>>
>> As part of this change, I'm also dropping '2>/dev/null' from objcopy
>> invocation to be able to catch possible other issues (objcopy doesn't
>> produce any warnings for me anymore, it did before with --dump-section).
> 
> Agree dropping /dev/null seems like a good choice. Otherwise seems reasonable
> to me.
> 
> Acked-by: John Fastabend <john.fastabend@...il.com>

Could reproduce as well:

root@...c:~/bpf# xxd .btf.vmlinux.bin.old | head -n1                   (original)
00000000: 9feb 0100 1800 0000 0000 0000 5088 2000  ............P. .

root@...c:~/bpf# ls -l .btf.vmlinux.bin.old
-rw-r--r-- 1 root root 3439882 Nov 29 15:59 .btf.vmlinux.bin.old


root@...c:~/bpf# xxd .btf.vmlinux.bin.new-buggy | head -n1             ('bpf: Support pre-2.25-binutils objcopy for vmlinux BTF')
00000000: 0000 0000 0000 0000 0000 0000 0000 0000  ................

root@...c:~/bpf# ls -l .btf.vmlinux.bin.new-buggy
-rwxr-xr-x 1 root root 45705482 Nov 29 16:01 .btf.vmlinux.bin.new-buggy


root@...c:~/bpf# xxd .btf.vmlinux.bin.new-fixed | head -n1             ('bpf: Force .BTF section start to zero when dumping from vmlinux')
00000000: 9feb 0100 1800 0000 0000 0000 5088 2000  ............P. .

root@...c:~/bpf# ls -l .btf.vmlinux.bin.new-fixed
-rwxr-xr-x 1 root root 3439882 Nov 29 16:02 .btf.vmlinux.bin.new-fixed


root@...c:~/bpf# diff .btf.vmlinux.bin.old .btf.vmlinux.bin.new-buggy
Binary files .btf.vmlinux.bin.old and .btf.vmlinux.bin.new-buggy differ

root@...c:~/bpf# diff .btf.vmlinux.bin.old .btf.vmlinux.bin.new-fixed
root@...c:~/bpf#


Applied, thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ