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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Fri, 11 Mar 2022 15:35:36 +1100
From:   Alexey Kardashevskiy <aik@...abs.ru>
To:     Michael Ellerman <mpe@...erman.id.au>,
        Fāng-ruì Sòng 
        <maskray@...gle.com>
Cc:     Nick Desaulniers <ndesaulniers@...gle.com>,
        Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        linuxppc-dev@...ts.ozlabs.org,
        Nathan Chancellor <nathan@...nel.org>,
        linux-kernel@...r.kernel.org, llvm@...ts.linux.dev
Subject: Re: [PATCH] powerpc: Replace ppc64 DT_RELACOUNT usage with
 DT_RELASZ/24



On 3/11/22 15:15, Michael Ellerman wrote:
> Fāng-ruì Sòng <maskray@...gle.com> writes:
>> On Thu, Mar 10, 2022 at 11:48 AM Nick Desaulniers
>> <ndesaulniers@...gle.com> wrote:
>>>
>>> On Tue, Mar 8, 2022 at 9:53 PM Fangrui Song <maskray@...gle.com> wrote:
>>>>
>>>> DT_RELACOUNT is an ELF dynamic tag inherited from SunOS indicating the
>>>> number of R_*_RELATIVE relocations. It is optional but {ld.lld,ld.lld}
>>>> -z combreloc always creates it (if non-zero) to slightly speed up glibc
>>>> ld.so relocation resolving by avoiding R_*R_PPC64_RELATIVE type
>>>> comparison. The tag is otherwise nearly unused in the wild and I'd
>>>> recommend that software avoids using it.
>>>>
>>>> lld>=14.0.0 (since commit da0e5b885b25cf4ded0fa89b965dc6979ac02ca9)
>>>> underestimates DT_RELACOUNT for ppc64 when position-independent long
>>>> branch thunks are used. Correcting it needs non-trivial arch-specific
>>>> complexity which I'd prefer to avoid. Since our code always compares the
>>>> relocation type with R_PPC64_RELATIVE, replacing every occurrence of
>>>> DT_RELACOUNT with DT_RELASZ/sizeof(Elf64_Rela)=DT_RELASZ/24 is a correct
>>>> alternative.
>>>
>>> checking that sizeof(Elf64_Rela) == 24, yep: https://godbolt.org/z/bb4aKbo5T
>>>
>>>>
>>>> DT_RELASZ is in practice bounded by an uint32_t. Dividing x by 24 can be
>>>> implemented as (uint32_t)(x*0xaaaaaaab) >> 4.
>>>
>>> Yep: https://godbolt.org/z/x9445ePPv
>>>
>>>>
>>>> Link: https://github.com/ClangBuiltLinux/linux/issues/1581
>>>> Reported-by: Nathan Chancellor <nathan@...nel.org>
>>>> Signed-off-by: Fangrui Song <maskray@...gle.com>
>>>> ---
>>>>   arch/powerpc/boot/crt0.S       | 28 +++++++++++++++++-----------
>>>>   arch/powerpc/kernel/reloc_64.S | 15 +++++++++------
>>>>   2 files changed, 26 insertions(+), 17 deletions(-)
> ...
> 
>> I rebased the patch on
>> git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
>> master and got a conflict.
>> Seems that https://lore.kernel.org/linuxppc-dev/20220309061822.168173-1-aik@ozlabs.ru/T/#u
>> ("[PATCH kernel v4] powerpc/64: Add UADDR64 relocation support") fixed
>> the issue.
>> It just doesn't change arch/powerpc/boot/crt0.S
> 
> Yeah sorry, I applied Alexey's v4 just before I saw your patch arrive on
> the list.
> 
> If one of you can rework this so it applies on top that would be great :)


I guess it is me as now I have to add that UARRD64 thing to crt0.S as 
well, don't I?

And also we are giving up on the llvm ld having a bug with RELACOUNT?


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ