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: <20231109164007.2037721-1-kan.liang@linux.intel.com>
Date:   Thu,  9 Nov 2023 08:40:07 -0800
From:   kan.liang@...ux.intel.com
To:     acme@...nel.org, irogers@...gle.com, linux-kernel@...r.kernel.org,
        linux-perf-users@...r.kernel.org
Cc:     peterz@...radead.org, mingo@...hat.com, jolsa@...nel.org,
        namhyung@...nel.org, adrian.hunter@...el.com,
        tinghao.zhang@...el.com, Kan Liang <kan.liang@...ux.intel.com>,
        Arnaldo Carvalho de Melo <acme@...hat.com>
Subject: [PATCH] perf evsel: Ignore the non-group case for branch counters

From: Kan Liang <kan.liang@...ux.intel.com>

The perf test 27: Sample parsing fails with the branch counters support
introduced.

The branch counters feature requires all the events to belong to a
group. There is no problem with the normal perf usage which usually
initializes an evlist even for a single evsel.
But the perf test is special, which may not initialize an evlist. The
Sample parsing test case is one of the examples. The existing code
crashes with the !evsel->evlist.

Non-group means the evsel doesn't have branch counters support.

Reported-by: Arnaldo Carvalho de Melo <acme@...hat.com>
Closes: https://lore.kernel.org/lkml/ZUv+G+w5EvJgQS45@kernel.org/
Signed-off-by: Kan Liang <kan.liang@...ux.intel.com>
---
 tools/perf/util/evsel.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 58a9b8c82790..7a6a2d1f96db 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -2355,6 +2355,10 @@ static inline bool evsel__has_branch_counters(const struct evsel *evsel)
 {
 	struct evsel *cur, *leader = evsel__leader(evsel);
 
+	/* The branch counters feature only supports group */
+	if (!leader || !evsel->evlist)
+		return false;
+
 	evlist__for_each_entry(evsel->evlist, cur) {
 		if ((leader == evsel__leader(cur)) &&
 		    (cur->core.attr.branch_sample_type & PERF_SAMPLE_BRANCH_COUNTERS))
-- 
2.35.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ