Re: [PATCH] mm/kfence: add reboot notifier to disable KFENCE on shutdown
From: Breno Leitao
Date: Thu Nov 27 2025 - 06:12:21 EST
On Wed, Nov 26, 2025 at 10:14:53AM -0800, Andrew Morton wrote:
> On Wed, 26 Nov 2025 09:46:18 -0800 Breno Leitao <leitao@xxxxxxxxxx> wrote:
>
> > During system shutdown, KFENCE can cause IPI synchronization issues if
> > it remains active through the reboot process. To prevent this, register
> > a reboot notifier that disables KFENCE and cancels any pending timer
> > work early in the shutdown sequence.
> >
> > This is only necessary when CONFIG_KFENCE_STATIC_KEYS is enabled, as
> > this configuration sends IPIs that can interfere with shutdown. Without
> > static keys, no IPIs are generated and KFENCE can safely remain active.
> >
> > The notifier uses maximum priority (INT_MAX) to ensure KFENCE shuts
> > down before other subsystems that might still depend on stable memory
> > allocation behavior.
> >
> > This fixes a late kexec CSD lockup[1] when kfence is trying to IPI a CPU
> > that is busy in a IRQ-disabled context printing characters to the
> > console.
> >
> > Link: https://lore.kernel.org/all/sqwajvt7utnt463tzxgwu2yctyn5m6bjwrslsnupfexeml6hkd@v6sqmpbu3vvu/ [1]
>
> 6.13 kernels and earlier, so I assume we'll want a cc:stable on this.
> And I assume there's really no identifiable Fixes: target.
This infrastructure showed up when kfence was created, so, a possible
Fixes: target would point to commit 0ce20dd84089 ("mm: add Kernel
Electric-Fence infrastructure")