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-next>] [day] [month] [year] [list]
Message-ID: <20250609035542.2364525-1-tianyou.li@intel.com>
Date: Mon,  9 Jun 2025 11:55:42 +0800
From: Tianyou Li <tianyou.li@...el.com>
To: Peter Zijlstra <peterz@...radead.org>,
	Ingo Molnar <mingo@...hat.com>,
	Arnaldo Carvalho de Melo <acme@...nel.org>,
	Namhyung Kim <namhyung@...nel.org>
Cc: Mark Rutland <mark.rutland@....com>,
	Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
	Jiri Olsa <jolsa@...nel.org>,
	Ian Rogers <irogers@...gle.com>,
	Adrian Hunter <adrian.hunter@...el.com>,
	Kan Liang <kan.liang@...ux.intel.com>,
	tianyou.li@...el.com,
	wangyang.guo@...el.com,
	linux-perf-users@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH] Add --buildids-blacklist option to perf archive command

When make a perf archive, it may contains the binaries that user did not want to ship with,
add --buildids-blacklist option to specify a backlist file which contains the buildids need
to be excluded. The blacklist file can be generated from command:

  perf buildid-list -i perf.data --with-hits | grep -v "^ " > buildids_blacklist.txt

Then remove the lines from the buildids_blacklist.txt for buildids should be included.

Signed-off-by: Tianyou Li <tianyou.li@...el.com>
Reviewed-by: Wangyang Guo <wangyang.guo@...el.com>
---
 tools/perf/perf-archive.sh | 35 ++++++++++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 5 deletions(-)

diff --git a/tools/perf/perf-archive.sh b/tools/perf/perf-archive.sh
index 6ed7e52ab881..e5ff840ac6b4 100755
--- a/tools/perf/perf-archive.sh
+++ b/tools/perf/perf-archive.sh
@@ -16,6 +16,13 @@ while [ $# -gt 0 ] ; do
 	elif [ $1 == "--unpack" ]; then
 		UNPACK=1
 		shift
+	elif [ $1 == "--buildids-blacklist" ]; then
+		BUILDIDS_BLACKLIST="$2"
+		if [ ! -e "$BUILDIDS_BLACKLIST" ]; then
+			echo "Provided buildids blacklist file $BUILDIDS_BLACKLIST does not exist"
+			exit 1
+		fi
+		shift 2
 	else
 		PERF_DATA=$1
 		UNPACK_TAR=$1
@@ -86,11 +93,29 @@ fi
 
 BUILDIDS=$(mktemp /tmp/perf-archive-buildids.XXXXXX)
 
-perf buildid-list -i $PERF_DATA --with-hits | grep -v "^ " > $BUILDIDS
-if [ ! -s $BUILDIDS ] ; then
-	echo "perf archive: no build-ids found"
-	rm $BUILDIDS || true
-	exit 1
+#
+# BUILDIDS_BLACKLIST is an optional file that contains build-ids to be excluded from the
+# archive. It is a list of build-ids, one per line, without any leading or trailing spaces.
+# If the file is empty, all build-ids will be included in the archive. To create a blacklist
+# file, you can use the following command:
+# 	perf buildid-list -i perf.data --with-hits | grep -v "^ " > buildids_blacklist.txt
+# You can edit the file to remove the lines that you want to keep in the archive, then:
+# 	perf archive --buildids-blacklist buildids_blacklist.txt
+#
+if [ ! -s $BUILDIDS_BLACKLIST ]; then
+	perf buildid-list -i $PERF_DATA --with-hits | grep -v "^ " > $BUILDIDS
+	if [ ! -s $BUILDIDS ] ; then
+		echo "perf archive: no build-ids found"
+		rm $BUILDIDS || true
+		exit 1
+	fi
+else
+	perf buildid-list -i $PERF_DATA --with-hits | grep -v "^ " | grep -Fv -f $BUILDIDS_BLACKLIST > $BUILDIDS
+	if [ ! -s $BUILDIDS ] ; then
+		echo "perf archive: no build-ids found after applying blacklist"
+		rm $BUILDIDS || true
+		exit 1
+	fi
 fi
 
 MANIFEST=$(mktemp /tmp/perf-archive-manifest.XXXXXX)
-- 
2.47.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ