mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1 1/3] perf synthetic-events: Ensure features are aligned
@ 2024-12-12  8:05 Ian Rogers
  2024-12-12  8:05 ` [PATCH v1 2/3] perf machine: Avoid UB by delaying computing branch entries Ian Rogers
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ian Rogers @ 2024-12-12  8:05 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, Kan Liang, Sun Haiyong, Yanteng Si,
	linux-perf-users, linux-kernel

Features like hostname have arbitrary size and break the assumed
8-byte alignment of perf events. Pad all feature events until 8-byte
alignment is restored.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/util/synthetic-events.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c
index f8ac2ac2da45..5b14244253b5 100644
--- a/tools/perf/util/synthetic-events.c
+++ b/tools/perf/util/synthetic-events.c
@@ -2401,6 +2401,11 @@ int perf_event__synthesize_features(const struct perf_tool *tool, struct perf_se
 			pr_debug("Error writing feature\n");
 			continue;
 		}
+		while (PERF_ALIGN(ff.offset, sizeof(u64)) != ff.offset) {
+			char c = 0;
+
+			do_write(&ff, &c, 1);
+		}
 		/* ff.buf may have changed due to realloc in do_write() */
 		fe = ff.buf;
 		memset(fe, 0, sizeof(*fe));
-- 
2.47.1.613.gc27f4b7a9f-goog


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

end of thread, other threads:[~2024-12-14 19:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-12  8:05 [PATCH v1 1/3] perf synthetic-events: Ensure features are aligned Ian Rogers
2024-12-12  8:05 ` [PATCH v1 2/3] perf machine: Avoid UB by delaying computing branch entries Ian Rogers
2024-12-12  8:05 ` [PATCH v1 3/3] perf record: Assert synthesized events are 8-byte aligned Ian Rogers
2024-12-14 19:32 ` [PATCH v1 1/3] perf synthetic-events: Ensure features are aligned Ian Rogers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®