From: Mike Rapoport <rppt@kernel.org>
To: "Baek Kyu, Kim" <pocj8ur4in@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>,
Lorenzo Stoakes <ljs@kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] mm/secretmem: Keep locked memory accounting until inode eviction
Date: Sun, 29 Nov 2026 17:50:01 +0200 [thread overview]
Message-ID: <awxJqR8gJLj_y0h9@kernel.org> (raw)
In-Reply-To: <179586776810.146060.16432032400935006500.c113-v3@gmail.com>
Hi Kim,
On Sat, Nov 28, 2026 at 09:09:28PM +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.
...
> mapping_set_gfp_mask(inode->i_mapping, GFP_USER);
> @@ -309,14 +295,14 @@ static struct file *secretmem_file_create(unsigned long flags)
> inode->i_mode |= S_IFREG;
> inode->i_size = 0;
>
> - atomic_inc(&secretmem_users);
> -
> return file;
> -err_free_priv:
> - secretmem_destroy_inode_priv(inode);
> err_free_inode:
> iput(inode);
> return ERR_PTR(err);
> +err_free_state:
> + free_uid(state->user);
> + kfree(state);
> + return ERR_PTR(err);
I was mistaken, and v1 with if (!state) in secretmem_evict_inode() looked
better.
The only thing that was missing there was a comment how we can reach
secretmem_evict_inode() with zero state.
--
Sincerely yours,
Mike.
prev parent reply other threads:[~2026-11-29 15:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 12:09 [PATCH v3] mm/secretmem: Keep locked memory accounting until inode eviction Baek Kyu, Kim
2026-11-29 15:50 ` Mike Rapoport [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=awxJqR8gJLj_y0h9@kernel.org \
--to=rppt@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=pocj8ur4in@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox