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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwvOd=gDxwvBdtDrJmqo4yb2DoswHtcK6f2M+z4s-b1RK5DyQ@mail.gmail.com>
Date:   Thu, 14 Oct 2021 13:59:12 -0700
From:   Nick Desaulniers <ndesaulniers@...gle.com>
To:     Masahiro Yamada <masahiroy@...nel.org>
Cc:     Catalin Marinas <catalin.marinas@....com>,
        Will Deacon <will@...nel.org>, llvm@...ts.linux.dev,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        linux-arm-kernel <linux-arm-kernel@...ts.infradead.org>,
        Vincenzo Frascino <vincenzo.frascino@....com>,
        Lucas Henneman <henneman@...gle.com>
Subject: Re: [PATCH 2/3] arm64: vdso32: lazily invoke COMPAT_CC

On Tue, Oct 12, 2021 at 8:03 PM Masahiro Yamada <masahiroy@...nel.org> wrote:
>
> On Wed, Oct 13, 2021 at 8:46 AM Nick Desaulniers
> <ndesaulniers@...gle.com> wrote:
> >
> > When running the following command without arm-linux-gnueabi-gcc in
> > one's $PATH, the following warning is observed:
> >
> > $ ARCH=arm64 CROSS_COMPILE_COMPAT=arm-linux-gnueabi- make -j72 LLVM=1 mrproper
> > make[1]: arm-linux-gnueabi-gcc: No such file or directory
> >
> > This is because KCONFIG is not run for mrproper, so CONFIG_CC_IS_CLANG
> > is not set, and we end up eagerly evaluating various variables that try
> > to invoke CC_COMPAT.
> >
> > This is a similar problem to what was observed in
> > commit 3ec8a5b33dea ("kbuild: do not export LDFLAGS_vmlinux")
> >
> > Cc: Masahiro Yamada <masahiroy@...nel.org>
> > Reported-by: Lucas Henneman <henneman@...gle.com>
> > Signed-off-by: Nick Desaulniers <ndesaulniers@...gle.com>
>
>
> There are two ways to fix it:
>
>   [1]: sink the error message to /dev/null
>         (as in commit dc960bfeedb01cf832c5632ed1f3daed4416b142)
>   [2]: use a recursively-expanded variable as you did.
>
>
> "Simple variable (:=) vs recursive variable (=)" is a trade-off.
>
> Please be careful about the cost when you try the [2] approach.
>
>
>
> Simple variables are immediately expanded while parsing Makefile.
> There are 7 call-sites for cc32-option, hence
> the compiler is invoked 7 times for building vdso32,
> 0 times for cleaning.
> (Since 57fd251c789647552d32d2fc51bedd4f90d70f9f,
> try-run is no-op for 'make clean').
>
>
>
>
> Recursive variables are expanded every time they are used.
>
> IIUC, if_changed expands the command line 3 times.
> There are 2 objects (note.o and vgettimeofday.o)
> There are 7 call-sites for cc32-option.
>
> So, the compiler is invoked 42 (3 * 2 * 7) times
> for building vdso32.

With this patch applied:
$ ARCH=arm64 CROSS_COMPILE_COMPAT=arm-linux-gnueabi- make LLVM=1 -j72
clean defconfig
$ ARCH=arm64 CROSS_COMPILE_COMPAT=arm-linux-gnueabi- make LLVM=1 -j72
arch/arm64/kernel/vdso32/ V=1 | tr -s ' ' | cut -d ' ' -f 2 | grep
clang | wc -l
55
$ find arch/arm64/kernel/vdso32/ -name \*.o | xargs rm
$ ARCH=arm64 CROSS_COMPILE_COMPAT=arm-linux-gnueabi- make LLVM=1 -j72
arch/arm64/kernel/vdso32/ V=1 | tr -s ' ' | cut -d ' ' -f 2 | grep
clang | wc -l
2

Prior to this series:
$ ARCH=arm64 CROSS_COMPILE_COMPAT=arm-linux-gnueabi- make LLVM=1 -j72
clean defconfig
$ ARCH=arm64 CROSS_COMPILE_COMPAT=arm-linux-gnueabi- make LLVM=1 -j72
arch/arm64/kernel/vdso32/ V=1 | tr -s ' ' | cut -d ' ' -f 2 | grep
clang | wc -l
55
$ find arch/arm64/kernel/vdso32/ -name \*.o | xargs rm
$ ARCH=arm64 CROSS_COMPILE_COMPAT=arm-linux-gnueabi- make LLVM=1 -j72
arch/arm64/kernel/vdso32/ V=1 | tr -s ' ' | cut -d ' ' -f 2 | grep
clang | wc -l
2

With patch 3 applied, we can drop CROSS_COMPILE_COMPAT, and we now get:
$ ARCH=arm64 make LLVM=1 -j72 clean defconfig
ARCH=arm64 make LLVM=1 -j72 arch/arm64/kernel/vdso32/ V=1 | tr -s ' '
| cut -d ' ' -f 2 | grep clang | wc -l
44
$ find arch/arm64/kernel/vdso32/ -name \*.o | xargs rm
$ ARCH=arm64 make LLVM=1 -j72 arch/arm64/kernel/vdso32/ V=1 | tr -s '
' | cut -d ' ' -f 2 | grep clang | wc -l
2

Please confirm; perhaps my pipeline missed some invocations? Or was
there a different target you were referring to?

--
Thanks,
~Nick Desaulniers

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ