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: <CAKwvOdnk8ofgW+4D8HnFBqgoi49vkLHqsAMCtM=SpuKyJHVkaQ@mail.gmail.com>
Date:   Fri, 4 Aug 2023 09:15:54 -0700
From:   Nick Desaulniers <ndesaulniers@...gle.com>
To:     Xi Ruoyao <xry111@...111.site>
Cc:     Huacai Chen <chenhuacai@...nel.org>,
        WANG Xuerui <kernel@...0n.name>,
        Nathan Chancellor <nathan@...nel.org>,
        loongarch@...ts.linux.dev, llvm@...ts.linux.dev,
        linux-kernel@...r.kernel.org, WANG Xuerui <git@...0n.name>
Subject: Re: [PATCH] LoongArch: Drop -ffreestanding from CFLAGS

On Fri, Aug 4, 2023 at 8:56 AM Xi Ruoyao <xry111@...111.site> wrote:
>
> On Fri, 2023-08-04 at 08:46 -0700, Nick Desaulniers wrote:
> > > Not all processors support unaligned access, so we need the
> > > alternative mechanism to select memset/memcpy/memmove implementations.
> > > If remove -ffreestanding, the builtin implementation cannot be used on
> > > all hardware.
> >
> > That sounds like a compiler bug in that compiler's implementation of
> > string.h builtins then; it should default to the safest implementation
> > (aligned accesses) until instructed otherwise.  Have you filed a bug
> > against your compiler vendor for which compiler you observe that
> > behavior from?
>
> AFAIK there is no such bug in GCC.
>
> But GCC indeed has a bug about builtin expansion: it generates really
> stupid code for __builtin_memcpy and friends.  See
> https://gcc.gnu.org/PR109465.  The bug is fixed for GCC 14, but GCC 14
> won't be released soon.

Perhaps -fno-builtin-* flags may be of help here, and more precise an
incision than the blunt -ffreestanding.

>
> > At the very least, there should be a comment above the addition of
> > -ffreestanding justifying why it's being used, probably with a link to
> > the above bug report.
> >
> > I would expect either -mcpu or perhaps some other -m flag to guide the
> > compiler when it is safe to emit memcpy (and friends) in terms of
> > unaligned access or not.
>
> It's controlled by -m{no-,}strict-align.  LoongArch kernel defaults to -
> mstrict-align, with this the compiler should not generate unaligned
> access.  -mno-strict-align is hidden behind CONFIG_EXPERT (FWIW I
> personally dislike the decision to hide it).

If GCC generates unaligned accesses in its implementation of
__builtin_memcpy when -mstrict-align is set, then that is a bug in GCC
and should be reported.

Clang users should not have to pay for such mistakes.

>
> --
> Xi Ruoyao <xry111@...111.site>
> School of Aerospace Science and Technology, Xidian University



-- 
Thanks,
~Nick Desaulniers

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ