From: Mike Rapoport <rppt@kernel.org>
To: Pratyush Yadav <pratyush@kernel.org>
Cc: Alexander Graf <graf@amazon.com>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
Hugh Dickins <hughd@google.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Andrew Morton <akpm@linux-foundation.org>,
Jason Gunthorpe <jgg@nvidia.com>,
Samiullah Khawaja <skhawaja@google.com>,
kexec@lists.infradead.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] mm: memfd_luo: preserve file seals
Date: Mon, 26 Jan 2026 16:37:23 +0200 [thread overview]
Message-ID: <aXd8I4czYUpl72qq@kernel.org> (raw)
In-Reply-To: <2vxzqzrca6cm.fsf@kernel.org>
Hi Pratyush,
On Mon, Jan 26, 2026 at 01:47:21PM +0100, Pratyush Yadav wrote:
> Hi Mike,
>
> On Sun, Jan 25 2026, Mike Rapoport wrote:
> > On Fri, Jan 23, 2026 at 10:58:51AM +0100, Pratyush Yadav wrote:
...
> >> - file = memfd_alloc_file("", 0);
> >> + /*
> >> + * The seals are preserved. Allow sealing here so they can be added
> >> + * later.
> >> + */
> >> + file = memfd_alloc_file("", MFD_ALLOW_SEALING);
> >
> > I think we should select flags passed to memfd_alloc_file() based on
> > ser->seals (and later based on ser->seals and ser->flags).
>
> Not sure what you mean.
>
> I think the only seal we can set via memfd_alloc_file() flags is
> MFD_NOEXEC_SEAL, which is really a F_SEAL_EXEC and plus a change of the
> inode's mode. And now that I think of it, that is a valid use case that
> we might as well support. But I think that should be done by preserving
> the mode of the inode directly, and then copying the seals back. The
> main reason for that is that the mode can be changed after the memfd is
> created too.
>
> Other than that, all other seals are set by fcntl (via
> memfd_add_seals()), so I don't see what else we can pass to
> memfd_alloc_file().
Hmm, "using ser->seals" was bad phrasing :)
Now we add support for creating memfd with MFD_ALLOW_SEALING and at some
point we'd want MFD_HUGETLB and huge page size.
So I think we should have a field in ser that will define what flags should
be used for creation of memfd and based on the value of that field pass the
flags to memfd_alloc_file().
For seals support this field can be hardwired to MFD_ALLOW_SEALING at preserve
time.
> >> if (IS_ERR(file)) {
> >> pr_err("failed to setup file: %pe\n", file);
> >> err = PTR_ERR(file);
> >> goto free_ser;
> >> }
> >>
> >> + err = memfd_add_seals(file, ser->seals);
> >
> > I'm not sure using MFD_ALLOW_SEALING is enough if there was F_SEAL_EXEC in
> > seals.
>
> Why not? memfd_add_seals() can handle F_SEAL_EXEC as far as I can tell.
I just noticed it behaved differently :)
Looks like F_SEAL_EXEC indeed can handle it.
> --
> Regards,
> Pratyush Yadav
--
Sincerely yours,
Mike.
next prev parent reply other threads:[~2026-01-26 14:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-23 9:58 [PATCH 0/2] mm: memfd_luo: preserve file seals Pratyush Yadav
2026-01-23 9:58 ` [PATCH 1/2] memfd: export memfd_{add,get}_seals() Pratyush Yadav
2026-01-25 11:52 ` Mike Rapoport
2026-01-23 9:58 ` [PATCH 2/2] mm: memfd_luo: preserve file seals Pratyush Yadav
2026-01-25 12:03 ` Mike Rapoport
2026-01-26 12:47 ` Pratyush Yadav
2026-01-26 14:37 ` Mike Rapoport [this message]
2026-02-10 13:15 ` Pratyush Yadav
2026-01-26 18:31 ` Jason Gunthorpe
2026-02-10 13:10 ` Pratyush Yadav
2026-02-10 13:13 ` Jason Gunthorpe
2026-02-10 13:53 ` Pratyush Yadav
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=aXd8I4czYUpl72qq@kernel.org \
--to=rppt@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=graf@amazon.com \
--cc=hughd@google.com \
--cc=jgg@nvidia.com \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pasha.tatashin@soleen.com \
--cc=pratyush@kernel.org \
--cc=skhawaja@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.