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]
Date:   Wed, 28 Sep 2022 10:21:36 +0100
From:   John Garry <john.garry@...wei.com>
To:     Will Chandler <wfc@...handler.org>, <peterz@...radead.org>,
        <mingo@...hat.com>, <acme@...nel.org>, <mark.rutland@....com>,
        <alexander.shishkin@...ux.intel.com>, <jolsa@...nel.org>,
        <namhyung@...nel.org>, <linux-perf-users@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] perf tools: Fix empty version number when building
 outside of a git repo

On 27/09/2022 20:52, Will Chandler wrote:
> When perf is built in a full source tree that is not a git repository,
> e.g. from a kernel source tarball, `perf version` will print empty tag
> and commit strings:
> 
>    $ perf version
>    perf version
> 
> Currently the tag version is only generated from the root Makefile when
> building in a git repository. If PERF-VERSION-FILE has not been
> generated and the source tree is not in a git repository, then
> PERF-VERSION-GEN will return an empty version.
> 
> The problem can be reproduced with the following steps:
> 
>    $ wget https://git.kernel.org/torvalds/t/linux-6.0-rc7.tar.gz
>    $ tar -xf linux-6.0-rc7.tar.gz && cd linux-6.0-rc7
>    $ make -C tools/perf
>    $ tools/perf/perf -v
>    perf version
> 
> Builds from tarballs generated with `make perf-tar-src-pkg` are not
> impacted by this issue as PERF-VERSION-FILE is included in the archive.
> 
> The perf RPM provided by Fedora for 5.18+ is experiencing this problem.
> Package build logs[0] show that the build is attempting to fall back on
> PERF-VERSION-FILE, but it is not present.
> 
> To resolve this, always use the tag from the root Makefile if available.
> 
> [0] https://kojipkgs.fedoraproject.org/packages/kernel-tools/5.19.4/200.fc36/data/logs/x86_64/build.log
> 

Sorry for the breakage. I only considered perf-tar-src-pkg for 
out-of-git building.

> Fixes: 7572733b8499 ("perf tools: Fix version kernel tag, 2022-02-21")
> Signed-off-by: Will Chandler <wfc@...handler.org>
> ---
>   tools/perf/util/PERF-VERSION-GEN | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/util/PERF-VERSION-GEN b/tools/perf/util/PERF-VERSION-GEN
> index 0ee5af529238..43b8a8ea6f53 100755
> --- a/tools/perf/util/PERF-VERSION-GEN
> +++ b/tools/perf/util/PERF-VERSION-GEN
> @@ -15,10 +15,13 @@ LF='
>   #
>   CID=
>   TAG=
> -if test -d ../../.git -o -f ../../.git
> +if test -r ../../Makefile
>   then
>   	TAG=$(MAKEFLAGS= make -sC ../.. kernelversion)
> -	CID=$(git log -1 --abbrev=12 --pretty=format:"%h" 2>/dev/null) && CID="-g$CID"
> +	if test -d ../../.git -o -f ../../.git
> +	then
> +	    CID=$(git log -1 --abbrev=12 --pretty=format:"%h" 2>/dev/null) && CID="-g$CID"
> +	fi
>   else
>   	TAG=$(cut -d' ' -f3 ../../PERF-VERSION-FILE | sed -e 's/\"//g')
>   fi

This looks ok. But did you consider going back to same flow as 
pre-7572733b8499 to avoid a Makefile check, like:

---8<----

CID=
TAG=
if test -d ../../.git -o -f ../../.git
then
TAG=$(MAKEFLAGS= make -sC ../.. kernelversion)
CID=$(git log -1 --abbrev=12 --pretty=format:"%h" 2>/dev/null) && 
CID="-g$CID"
elif test -f ../../PERF-VERSION-FILE
then
TAG=$(cut -d' ' -f3 ../../PERF-VERSION-FILE | sed -e 's/\"//g')
fi
if test -z "$TAG"
then
TAG=$(MAKEFLAGS= make -sC ../.. kernelversion)
fi

--->8---

The evaluation for $TAG is not really needed in the first leg since the 
fallback does the same thing, but just added for clarity.

Thanks,
John

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ