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: <CAKwvOdmt+p3KM23hz2BfheoWgEa0G9QKnAFYUP+EL2Ta5LXUUg@mail.gmail.com>
Date:   Fri, 4 Aug 2023 08:46:18 -0700
From:   Nick Desaulniers <ndesaulniers@...gle.com>
To:     Huacai Chen <chenhuacai@...nel.org>
Cc:     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:26 AM Huacai Chen <chenhuacai@...nel.org> wrote:
>
> Hi, Xuerui,
>
> On Fri, Aug 4, 2023 at 8:56 PM WANG Xuerui <kernel@...0n.name> wrote:
> >
> > From: WANG Xuerui <git@...0n.name>
> >
> > As explained by Nick in the original issue: the kernel usually does a
> > good job of providing library helpers that have similar semantics as
> > their ordinary userspace libc equivalents, but -ffreestanding disables
> > such libcall optimization and other related features in the compiler,
> > which can lead to unexpected things such as CONFIG_FORTIFY_SOURCE not
> > working (!).
> >
> > As it turns out to be the case, removing the flag does not impact the
> > LoongArch kernel's normal operation at all; so just remove it to
> > restore expected libcall semantics globally on this architecture.
> >
> 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?

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.

>
> Huacai
>
> > Closes: https://github.com/ClangBuiltLinux/linux/issues/1897
> > Reported-by: Nathan Chancellor <nathan@...nel.org>
> > Suggested-by: Nick Desaulniers <ndesaulniers@...gle.com>
> > Signed-off-by: WANG Xuerui <git@...0n.name>
> > ---
> >  arch/loongarch/Makefile | 1 -
> >  1 file changed, 1 deletion(-)
> >
> > diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile
> > index b1e5db51b61c..db0d7210272d 100644
> > --- a/arch/loongarch/Makefile
> > +++ b/arch/loongarch/Makefile
> > @@ -83,7 +83,6 @@ KBUILD_CFLAGS_KERNEL          += -fPIE
> >  LDFLAGS_vmlinux                        += -static -pie --no-dynamic-linker -z notext
> >  endif
> >
> > -cflags-y += -ffreestanding
> >  cflags-y += $(call cc-option, -mno-check-zero-division)
> >
> >  load-y         = 0x9000000000200000
> > --
> > 2.40.0
> >
>


-- 
Thanks,
~Nick Desaulniers

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ