Re: [PATCH] rv: Represent uninitialised and dying DA monitors
From: Gabriele Monaco
Date: Tue Dec 01 2026 - 10:36:21 EST
On Tue, 2026-12-01 at 08:34 +0100, Gabriele Monaco wrote:
> DA monitors overload the monitoring field to represent states that don't
> belong to it. For example, it is used to understand whether a timer (HA)
> was set up and hence needs cancelling.
> Racing events may cause a monitor to reset it's monitoring flag while
> concurrently a timer is started, so the monitoring flag loses meaning.
>
> Add 2 new flags in the struct da_monitor without increasing it's size:
> * started: the monitor was started at least once
> * dead: the destruction of the monitor was started
>
> These flags keep their status on reset and allow to understand when a
> monitor needs a timer to be set-up, can cancel an already initialised
> timer, or should stop starting/handling events to avoid races.
>
> These flags don't avoid use after free issues by themselves, but coupled
> with an RCU grace period before freeing monitors (where applicable), can
> guarantee no resources are used after free.
>
> Fixes: 700782ec8f65 ("rv: Add automatic cleanup handlers for per-task HA
> monitors")
> Fixes: f5587d1b6ec9 ("rv: Add Hybrid Automata monitor type")
> Signed-off-by: Gabriele Monaco <gmonaco@xxxxxxxxxx>
> ---
This approach is yet again opening a can of worms..
In the end of the day what Karl proposed (initialise timers once at the
beginning) is probably the best and simplest solution.
I'm going to try and draft something like that, adding a path for per-task
monitors too.
Gabriele