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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 20 Aug 2020 12:18:35 +0200
From:   Mark Wielaard <mark@...mp.org>
To:     Yonghong Song <yhs@...com>,
        Fāng-ruì Sòng <maskray@...gle.com>,
        Jiri Olsa <jolsa@...nel.org>
Cc:     Nick Desaulniers <ndesaulniers@...gle.com>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Nick Clifton <nickc@...hat.com>,
        Jesper Dangaard Brouer <brouer@...hat.com>,
        Network Development <netdev@...r.kernel.org>,
        bpf <bpf@...r.kernel.org>, Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>,
        Andrii Nakryiko <andriin@...com>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...omium.org>,
        clang-built-linux <clang-built-linux@...glegroups.com>
Subject: Re: [PATCH bpf-next] tools/resolve_btfids: Fix sections with wrong
 alignment

Hi,

On Wed, 2020-08-19 at 20:23 -0700, Yonghong Song wrote:
> On 8/19/20 7:27 PM, Fāng-ruì Sòng wrote:
> > > > > 
> > I think this is resolve_btfids's bug. GNU ld and LLD are innocent.
> > These .debug_* sections work fine if their sh_addralign is 1.
> > When the section flag SHF_COMPRESSED is set, the meaningful
> > alignment
> > is Elf64_Chdr::ch_addralign, after the header is uncompressed.
> > 
> > On Wed, Aug 19, 2020 at 2:30 PM Yonghong Song <yhs@...com> wrote:
> Since Fangrui mentioned this is not a ld/lld bug, then changing
> alighment from 1 to 4 might have some adverse effect for the binary,
> I guess.

The bug isn't about a wrong ch_addralign, which seems to have been set
correctly. But it is a bug about incorrectly setting the sh_addralign
of the section. The sh_addralign indicates the alignment of the data in
the section, which is the Elf32/64_Chdr plus compressed data, not the
alignment of the uncompressed data. It helps the consumer make sure
they lay out the data so that the ELF data structures can be read
through their natural alignment.

In practice it often isn't a real issue, because consumers, including
libelf, will correct the data alignment before usage anyway. But that
doesn't mean it isn't a bug to set it wrongly.

> Do you think we could skip these .debug_* sections somehow in elf 
> parsing in resolve_btfids? resolve_btfids does not need to read
> these sections. This way, no need to change their alignment either.

The issue is that elfutils libelf will not allow writing out the
section when it notices the sh_addralign field is setup wrongly.

Cheers,

Mark

Powered by blists - more mailing lists