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: <1c12cd26-d8aa-4498-f4c0-29478b9578fe@gmx.de>
Date:   Fri, 27 May 2022 15:57:26 +0200
From:   Helge Deller <deller@....de>
To:     Masahiro Yamada <masahiroy@...nel.org>,
        linux-kbuild@...r.kernel.org
Cc:     linux-kernel@...r.kernel.org,
        Peter Zijlstra <peterz@...radead.org>,
        Josh Poimboeuf <jpoimboe@...hat.com>, llvm@...ts.linux.dev,
        linux-parisc@...r.kernel.org,
        "James E.J. Bottomley" <James.Bottomley@...senPartnership.com>
Subject: Re: [PATCH v7 3/8] parisc: fix the exit status of arch/parisc/nm

Hello Masahiro,

On 5/27/22 12:01, Masahiro Yamada wrote:
> parisc overrides 'nm' with a shell script. I do not know the reason,
> but anyway it is how it has worked since 2003. [1]

I don't know the reason either...
I assume it was that the older toolchains had bugs and kept lots of local
symbols like .LC? in the object files.

I did a small build without the nm script (and removed it's reference
in the Makefile), and it did not seem to break anything.

> A problem is that this script returns the exit code of grep instead of
> ${CROSS_COMPILE}nm.

Instead of fixing this, I'd suggest that you simply remove the nm script
alltogether. If you like I can apply such a patch in the parisc git tree,
and you just drop this specific patch. Or you change your patch to remove it.
Just let me know what you prefer.

Helge

> grep(1) says:
>     Normally the exit status is 0 if a line is selected, 1 if no lines
>     were selected, and 2 if an error occurred. However, if the -q or
>     --quiet or --silent is used and a line is selected, the exit status
>     is 0 even if an error occurred.
>
> When the given object has no symbol, grep returns 1, while the true nm
> returns 0. Hence, build rules using ${NM} fail on ARCH=parisc even if
> the given object is valid.
>
> This commit corrects the exit status of the script.
>
>  - A pipeline returns the exit status of the last command (here, grep).
>    The exit status of ${CROSS_COMPILE}nm is just ignored. Use bash's
>    pipefail flag to catch errors of ${CROSS_COMPILE}nm.
>
>  - If grep returns 1, this script should return 0 in order to mimic
>    true nm. If grep returns 2, it is a real and fatal error. Return
>    it as is.
>
> [1]: https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=36eaa6e4c0e0b6950136b956b72fd08155b92ca3
>
> Signed-off-by: Masahiro Yamada <masahiroy@...nel.org>
> ---
>
> Changes in v7:
>   - New patch
>
>  arch/parisc/Makefile |  2 +-
>  arch/parisc/nm       | 12 ++++++++++--
>  2 files changed, 11 insertions(+), 3 deletions(-)
>  mode change 100644 => 100755 arch/parisc/nm
>
> diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile
> index aca1710fd658..e7139955367d 100644
> --- a/arch/parisc/Makefile
> +++ b/arch/parisc/Makefile
> @@ -18,7 +18,7 @@
>  boot := arch/parisc/boot
>  KBUILD_IMAGE := $(boot)/bzImage
>
> -NM		= sh $(srctree)/arch/parisc/nm
> +NM		= $(srctree)/arch/parisc/nm
>  CHECKFLAGS	+= -D__hppa__=1
>
>  ifdef CONFIG_64BIT
> diff --git a/arch/parisc/nm b/arch/parisc/nm
> old mode 100644
> new mode 100755
> index c788308de33f..3e72238a91f3
> --- a/arch/parisc/nm
> +++ b/arch/parisc/nm
> @@ -1,6 +1,14 @@
> -#!/bin/sh
> +#!/bin/bash
>  ##
>  # Hack to have an nm which removes the local symbols.  We also rely
>  # on this nm being hidden out of the ordinarily executable path
>  ##
> -${CROSS_COMPILE}nm $* | grep -v '.LC*[0-9]*$'
> +
> +# use pipefail to catch error of ${CROSS_COMPILE}nm
> +set -o pipefail
> +
> +# grep exits with 1 if no lines were selected.
> +# If the given object has no symbol, grep returns 1, but it is not an error.
> +
> +${CROSS_COMPILE}nm "$@" |
> +{ grep -v '.LC*[0-9]*$' || { exit_code=$?; test $exit_code -eq 1 || exit $exit_code; } }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ