From 970ee70d1729186a584c88826e8f4ca27a58c289 Mon Sep 17 00:00:00 2001 From: Shrushti P K Date: Tue, 17 Nov 2026 23:39:08 +0530 Subject: [PATCH] telemetry: performance_monitor: fix manifest module entry offset enable_performance_counters() adds SOF_MAN_MODULE_OFFSET(mod_id), a byte offset, to a const struct sof_man_fw_desc pointer. The pointer arithmetic scales it by sizeof(struct sof_man_fw_desc), so module entry 0 is read 2704 bytes into the manifest instead of 52, and entry i at 52 * (52 + 116 * i). instance_max_count is then taken from unrelated memory past the manifest, which can fault or drive up to 65535 bogus ipc4_get_comp_dev() lookups per module, and the real instances are not reinitialized. It runs on every IPC4_PERF_MEASUREMENTS_STATE change to STOPPED, STARTED or PAUSED, for the base firmware manifest and every loaded library. Cast the descriptor to a byte pointer before adding the offset, as the other SOF_MAN_MODULE_OFFSET() users in lib_manager.c, llext_manager.c and helper-kernel.c already do. --- src/kernel/debug/telemetry/performance_monitor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/kernel/debug/telemetry/performance_monitor.c b/src/kernel/debug/telemetry/performance_monitor.c index 65adaba88bdb..9be5ba2d7cd8 100644 --- a/src/kernel/debug/telemetry/performance_monitor.c +++ b/src/kernel/debug/telemetry/performance_monitor.c @@ -483,7 +483,7 @@ __cold void disable_performance_counters(void) __cold int enable_performance_counters(void) { - struct sof_man_module *man_module; + const struct sof_man_module *man_module; struct comp_dev *dev; uint32_t comp_id; const struct sof_man_fw_desc *desc; @@ -508,8 +508,8 @@ __cold int enable_performance_counters(void) /* Reinitialize performance data for all created components */ for (int mod_id = 0 ; mod_id < desc->header.num_module_entries; mod_id++) { - man_module = - (struct sof_man_module *)(desc + SOF_MAN_MODULE_OFFSET(mod_id)); + man_module = (const struct sof_man_module *)((const uint8_t *)desc + + SOF_MAN_MODULE_OFFSET(mod_id)); for (int inst_id = 0; inst_id < man_module->instance_max_count; inst_id++) { comp_id = IPC4_COMP_ID(mod_id, inst_id);