Re: [PATCH] mm/secretmem: disable memfd_secret() if secretmem_init() fails
From: Mike Rapoport
Date: Wed Dec 02 2026 - 11:01:01 EST
On Wed, Dec 02, 2026 at 01:44:34PM +0100, David Hildenbrand (Arm) wrote:
> On 12/2/26 12:38, Mike Rapoport wrote:
> > From: "Mike Rapoport (Microsoft)" <rppt@xxxxxxxxxx>
> >
> > If kern_mount() fails in secretmem_init(), secretmem_mnt holds an error
> > pointer, but secretmem_enable remains set. A later memfd_secret() call
> > then dereferences secretmem_mnt in secretmem_file_create() and oopses.
> >
> > At fs_initcall time kern_mount() of a pseudo filesystem realistically
> > fails only when a memory allocation fails, so this is unlikely to happen
> > in practice.
> >
> > Clear secretmem_enable when kern_mount() fails, so that memfd_secret()
> > returns -ENOSYS as if secretmem was disabled.
> >
> > Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
> > Closes: https://sashiko.dev/bug/linux-ad411cd2-f343-445a-b61d-9fb3eb712762
> > Fixes: 4eb5bbde3ccb ("mm: fix dereferencing possible ERR_PTR")
> > Signed-off-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
> > ---
>
> Unlikely to happen, so I guess no need for stable.
Indeed
> Reviewed-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
>
> --
> Cheers,
>
> David
--
Sincerely yours,
Mike.