Re: [PATCH 1/3] watchdog: pretimeout: Protect governor access with RCU for NMI safety

From: Doug Anderson

Date: Thu Jul 30 2026 - 17:52:54 EST


Hi,

On Thu, Jul 30, 2026 at 2:33 PM Mayank Rungta via B4 Relay
<devnull+mrungta.google.com@xxxxxxxxxx> wrote:
>
> From: Mayank Rungta <mrungta@xxxxxxxxxx>
>
> Currently, watchdog_notify_pretimeout() acquires pretimeout_lock using
> spin_lock_irqsave() to safely dereference wdd->gov before invoking the
> pretimeout callback.
>
> On architectures supporting pseudo-NMIs (ARM64 GICv3), watchdog drivers
> may register their pretimeout warning interrupt (bark) as an NMI.
> Because spin_lock_irqsave() disables regular interrupts but leaves NMIs
> unmasked, if a pretimeout NMI fires while pretimeout_lock is already
> held by normal process context, attempting to re-acquire pretimeout_lock
> triggers an unrecoverable deadlock.
>
> To make pretimeout notifications completely safe to execute from NMI,
> convert read access to wdd->gov inside watchdog_notify_pretimeout() from
> a spinlock to lockless RCU. Use rcu_assign_pointer() when modifying
> wdd->gov and invoke synchronize_rcu() during governor unregister and
> pretimeout unregister routines.
>
> Signed-off-by: Mayank Rungta <mrungta@xxxxxxxxxx>
> ---
> drivers/watchdog/watchdog_pretimeout.c | 47 +++++++++++++++++++---------------
> include/linux/watchdog.h | 2 +-
> 2 files changed, 27 insertions(+), 22 deletions(-)

I pre-reviewed this for Mayank. I'm not an RCU expert, but this looks
right based on my understanding. My AI was also happy with it. ;-)

Reviewed-by: Douglas Anderson <dianders@xxxxxxxxxxxx>