All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf evsel: fix buffer offset when building the EPERM error string
@ 2026-11-04 10:36 Gu Bin
  2026-11-04 10:43 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Gu Bin @ 2026-11-04 10:36 UTC (permalink / raw)
  To: acme
  Cc: peterz, mingo, namhyung, mark.rutland, alexander.shishkin, jolsa,
	irogers, adrian.hunter, james.clark, linux-perf-users,
	linux-kernel

When building the EPERM error string, the scnprintf() that emits "No
permission to enable %s event" uses (msg, size) instead of (msg +
printed, size - printed) like every other line in this case, overwriting
the "Access to performance monitoring..." preamble and truncating the
following hint. The message shown to the user for a failed open with
EPERM is therefore garbled: the preamble is lost and stale bytes from
the overwritten content remain in the buffer.

Use the correct offset and remaining size.

Fixes: c1034eb06920 ("perf tool: Make perf tool aware of SELinux access control")
Signed-off-by: Gu Bin <gubin@cmss.chinamobile.com>
---
 tools/perf/util/evsel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index d060fca8090f..6d69f63b7fb1 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -4590,7 +4590,7 @@ int evsel__open_strerror(struct evsel *evsel, struct target *target,
 		}
 
 		if (err == EPERM)
-			printed += scnprintf(msg, size,
+			printed += scnprintf(msg + printed, size - printed,
 				"No permission to enable %s event.\n\n", evsel__name(evsel));
 
 		return printed + scnprintf(msg + printed, size - printed,
-- 
2.55.0.windows.3




^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-04 10:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04 10:36 [PATCH] perf evsel: fix buffer offset when building the EPERM error string Gu Bin
2026-11-04 10:43 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.