Skip to content

Commit 8b7e849

Browse files
Shrusti-pklgirdwood
authored andcommitted
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. Signed-off-by: Shrushti P K <shrusthi@labs.digiscrypt.com>
1 parent 6bb19f4 commit 8b7e849

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎src/kernel/debug/telemetry/performance_monitor.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ __cold void disable_performance_counters(void)
498498

499499
__cold int enable_performance_counters(void)
500500
{
501-
struct sof_man_module *man_module;
501+
const struct sof_man_module *man_module;
502502
struct comp_dev *dev;
503503
uint32_t comp_id;
504504
const struct sof_man_fw_desc *desc;
@@ -523,8 +523,8 @@ __cold int enable_performance_counters(void)
523523

524524
/* Reinitialize performance data for all created components */
525525
for (int mod_id = 0 ; mod_id < desc->header.num_module_entries; mod_id++) {
526-
man_module =
527-
(struct sof_man_module *)(desc + SOF_MAN_MODULE_OFFSET(mod_id));
526+
man_module = (const struct sof_man_module *)((const uint8_t *)desc +
527+
SOF_MAN_MODULE_OFFSET(mod_id));
528528

529529
for (int inst_id = 0; inst_id < man_module->instance_max_count; inst_id++) {
530530
comp_id = IPC4_COMP_ID(mod_id, inst_id);

0 commit comments

Comments
 (0)