Re: [PATCH 2/5] hibernation: ensure secretmem pages don't reach a snapshot

From: Mike Rapoport

Date: Wed Sep 23 2026 - 11:57:02 EST


On Wed, Sep 23, 2026 at 12:10:52PM +0200, David Hildenbrand (Arm) wrote:
> On 9/17/26 08:07, Mike Rapoport (Microsoft) wrote:
> > hibernation_available() checks for active secretmem users, but a secretmem
> > file can be created after this check and its pages may get into the
> > hibernation snapshot although they should not.
> >
> > Recheck secretmem state after userspace is frozen and abort hibernation if
> > secretmem is active.
> >
> > Signed-off-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
> > ---
> > kernel/power/hibernate.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
> > index d2479c69d71a4..281ad49411481 100644
> > --- a/kernel/power/hibernate.c
> > +++ b/kernel/power/hibernate.c
> > @@ -412,6 +412,11 @@ int hibernation_snapshot(int platform_mode)
> > if (error)
> > goto Close;
> >
> > + if (secretmem_active()) {
> > + error = -EBUSY;
> > + goto Thaw;
> > + }
> > +
>
> Should we instead recheck hibernation_available() like we do at the beginning of
> hibernate() before freezing?

I'm not sure it's possible to hotplug cxl at that tiny window, but yeah,
checking hibernation_available() is cleaner.

> --
> Cheers,
>
> David

--
Sincerely yours,
Mike.