Re: [PATCH 1/3] watchdog: pretimeout: Protect governor access with RCU for NMI safety
Doug Anderson <[email protected]> Thu, 30 Jul 2026 14:46:58 -0700
| Newsgroups | org.kernel.vger.linux-watchdog,org.kernel.vger.linux-arm-msm,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CAD=FV=V_7RLjcAtKk5MHiABj1rA2CTkPw2UY2gJnVzH=3Gbp5Q@mail.gmail.com> |
Hi, On Thu, Jul 30, 2026 at 2:33=E2=80=AFPM Mayank Rungta via B4 Relay <[email protected]> wrote: > > From: Mayank Rungta <[email protected]> > > 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 <[email protected]> > --- > 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 <[email protected]>