aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGabriele Monaco <gmonaco@redhat.com>2026-06-01 17:38:30 +0200
committerGabriele Monaco <gmonaco@redhat.com>2026-06-03 12:33:23 +0200
commitc3d016ea823a9941ab8cbcef01a500821ff0cf16 (patch)
treee8684c288c2200a1d7dac0659dadc865982acb0a /include
parente32d7f404d7d9dac307c1cd9a1fe132fa62ab6d6 (diff)
rv: Prevent in-flight per-task handlers from using invalid slots
Per-task monitors use a slot in the task_struct->rv[] array and store that locally (e.g. task_mon_slot), this slot is returned during the destruction process but currently hanlers can be running while that slot is returning and this race may lead to accessing an invalid slot. Synchronise with all in-flight tracepoint handlers using tracepoint_synchronize_unregister() before returning the slot. Fixes: f5587d1b6ec9 ("rv: Add Hybrid Automata monitor type") Fixes: a9769a5b9878 ("rv: Add support for LTL monitors") Suggested-by: Wen Yang <wen.yang@linux.dev> Reviewed-by: Nam Cao <namcao@linutronix.de> Link: https://lore.kernel.org/r/20260601153840.124372-4-gmonaco@redhat.com Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/rv/da_monitor.h4
-rw-r--r--include/rv/ltl_monitor.h1
2 files changed, 5 insertions, 0 deletions
diff --git a/include/rv/da_monitor.h b/include/rv/da_monitor.h
index 1459fb3dfee6..cc97cc5dfbfd 100644
--- a/include/rv/da_monitor.h
+++ b/include/rv/da_monitor.h
@@ -302,6 +302,9 @@ static int da_monitor_init(void)
/*
* da_monitor_destroy - return the allocated slot
+ *
+ * Wait for all in-flight handlers before returning the slot to avoid
+ * out-of-bound accesses.
*/
static inline void da_monitor_destroy(void)
{
@@ -310,6 +313,7 @@ static inline void da_monitor_destroy(void)
return;
}
+ tracepoint_synchronize_unregister();
da_monitor_reset_all();
rv_put_task_monitor_slot(task_mon_slot);
diff --git a/include/rv/ltl_monitor.h b/include/rv/ltl_monitor.h
index eff60cd61106..38e792401f76 100644
--- a/include/rv/ltl_monitor.h
+++ b/include/rv/ltl_monitor.h
@@ -77,6 +77,7 @@ static void ltl_monitor_destroy(void)
{
rv_detach_trace_probe(name, task_newtask, handle_task_newtask);
+ tracepoint_synchronize_unregister();
rv_put_task_monitor_slot(ltl_monitor_slot);
ltl_monitor_slot = RV_PER_TASK_MONITOR_INIT;
}