Re: [PATCH v4 RESEND] mm/secretmem: Keep locked memory accounting until inode eviction
From: Mike Rapoport
Date: Mon Nov 30 2026 - 01:56:11 EST
On Mon, Nov 30, 2026 at 12:20:21PM +0900, Baek Kyu, Kim wrote:
> A secretmem inode can outlive its original file. An O_PATH descriptor
> opened through /proc/self/fd keeps the inode and its unevictable folios
> alive after the mapping and original descriptor are closed. The file
> release path nevertheless drops the locked-memory charge, allowing the
> same user to reuse RLIMIT_MEMLOCK while those folios remain allocated.
>
> Move private-state and locked-memory accounting cleanup to inode eviction,
> after truncating the page cache. Keep secretmem_users active over the same
> lifetime so the hibernation guard covers retained secret pages.
>
> Initialize private state after creating the secure inode. The filesystem
> root and an inode evicted before state attachment have no private state,
> so skip private cleanup in those cases. Once state is attached, iput()
> handles file-creation failures and releases the user reference on eviction.
>
> Fixes: 97d34aa65c29 ("mm/secretmem: properly account locked pages")
> Signed-off-by: Baek Kyu, Kim <pocj8ur4in@xxxxxxxxx>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
> ---
> mm/secretmem.c | 30 +++++++++++++++++-------------
> 1 file changed, 17 insertions(+), 13 deletions(-)
--
Sincerely yours,
Mike.