Re: [PATCH] mm/secretmem: disable memfd_secret() if secretmem_init() fails

From: David Hildenbrand (Arm)

Date: Wed Dec 02 2026 - 10:05:34 EST


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.

Reviewed-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

--
Cheers,

David