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: <ZsiV0V5-UYFGkxPE@bergen>
Date: Fri, 23 Aug 2024 15:59:46 +0200
From: Nicolas Schier <nicolas@...sle.eu>
To: Masahiro Yamada <masahiroy@...nel.org>
Cc: Miguel Ojeda <ojeda@...nel.org>, Alexei Starovoitov <ast@...nel.org>,
	Daniel Borkmann <daniel@...earbox.net>,
	Andrii Nakryiko <andrii@...nel.org>,
	Martin KaFai Lau <martin.lau@...ux.dev>,
	Eduard Zingerman <eddyz87@...il.com>, Song Liu <song@...nel.org>,
	Yonghong Song <yonghong.song@...ux.dev>,
	John Fastabend <john.fastabend@...il.com>,
	KP Singh <kpsingh@...nel.org>, Stanislav Fomichev <sdf@...ichev.me>,
	Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
	bpf@...r.kernel.org, Nathan Chancellor <nathan@...nel.org>,
	linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org,
	patches@...ts.linux.dev
Subject: Re: [PATCH] kbuild: pahole-version: avoid errors if executing fails

On Fri 23 Aug 2024 02:28:28 GMT, Masahiro Yamada wrote:
> Date: Fri, 23 Aug 2024 02:28:28 +0900
> From: Masahiro Yamada <masahiroy@...nel.org>
> To: Miguel Ojeda <ojeda@...nel.org>
> Cc: Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann
>  <daniel@...earbox.net>, Andrii Nakryiko <andrii@...nel.org>, Martin KaFai
>  Lau <martin.lau@...ux.dev>, Eduard Zingerman <eddyz87@...il.com>, Song Liu
>  <song@...nel.org>, Yonghong Song <yonghong.song@...ux.dev>, John Fastabend
>  <john.fastabend@...il.com>, KP Singh <kpsingh@...nel.org>, Stanislav
>  Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>, Jiri Olsa
>  <jolsa@...nel.org>, bpf@...r.kernel.org, Nathan Chancellor
>  <nathan@...nel.org>, Nicolas Schier <nicolas@...sle.eu>,
>  linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org,
>  patches@...ts.linux.dev
> Subject: Re: [PATCH] kbuild: pahole-version: avoid errors if executing fails
> X-Mailing-List: linux-kbuild@...r.kernel.org
> Message-ID: <CAK7LNARhR=GGZ2Vr-SSog1yjnjh6iT7cCEe4mpYg889GhJnO9g@...l.gmail.com>
> 
> On Sun, Jul 28, 2024 at 9:55 PM Miguel Ojeda <ojeda@...nel.org> wrote:
> >
> > Like patch "rust: suppress error messages from
> > CONFIG_{RUSTC,BINDGEN}_VERSION_TEXT" [1], do not assume the file existing
> > and being executable implies executing it will succeed. Instead, bail
> > out if executing it fails for any reason.
> >
> > For instance, `pahole` may be built for another architecture, may be a
> > program we do not expect or may be completely broken:
> >
> >     $ echo 'bad' > bad-pahole
> >     $ chmod u+x bad-pahole
> >     $ make PAHOLE=./bad-pahole defconfig
> >     ...
> >     ./bad-pahole: 1: bad: not found
> >     init/Kconfig:112: syntax error
> >     init/Kconfig:112: invalid statement
> 
> 
> 
> Even with this patch applied, a syntax error can happen.
> 
> $ git log --oneline -1
> dd1c54d77f11 kbuild: pahole-version: avoid errors if executing fails
> $ echo 'echo' > bad-pahole
> $ chmod u+x bad-pahole
> $ make PAHOLE=./bad-pahole defconfig
> *** Default configuration is based on 'x86_64_defconfig'
> init/Kconfig:114: syntax error
> init/Kconfig:114: invalid statement
> make[2]: *** [scripts/kconfig/Makefile:95: defconfig] Error 1
> make[1]: *** [/home/masahiro/workspace/linux-kbuild/Makefile:680:
> defconfig] Error 2
> make: *** [Makefile:224: __sub-make] Error 2
> 

Do we have to catch all possibilities?  Then, what about this:


#!/bin/sh
trap "echo 0; exit 1" EXIT
set -e

output=$("$@" --version 2>/dev/null)

output=$(echo "${output}" |  sed -nE 's/^v([0-9]+)\.([0-9][0-9])$/\1\2/p')
if [ -z "${output}" ]; then
	echo "warning: pahole binary '$1' outputs incompatible version number, pahole will not be used." >&2
	exit 1
fi

echo "${output}"
trap EXIT



Kind regards,
Nicolas

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ