From: Pasha Tatashin <pasha.tatashin@soleen.com>
To: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>,
Tarun Sahu <tarunsahu@google.com>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, kexec@lists.infradead.org,
linux-mm@kvack.org
Subject: Re: [PATCH] mm/memfd_luo: validate serialized_data before conversion
Date: Thu, 11 Jun 2026 18:11:13 +0000 [thread overview]
Message-ID: <air5ho0LOIEKVzRG@plex> (raw)
In-Reply-To: <airGIioUmTtU9326@kernel.org>
On 06-11 17:28, Mike Rapoport wrote:
> On Thu, Jun 11, 2026 at 03:37:12PM +0200, Pratyush Yadav wrote:
> > On Thu, Jun 11 2026, Mike Rapoport wrote:
> >
> > > On Thu, Jun 11, 2026 at 10:30:03AM +0000, Tarun Sahu wrote:
> > >> In memfd_luo_finish() and memfd_luo_retrieve(), phys_to_virt() was called
> > >> on args->serialized_data before checking if the physical address is valid.
> > >> Since physical address 0 does not map to virtual NULL (due to direct
> > >> mapping offsets), the subsequent check 'if (!ser)' was ineffective at
> > >> catching a missing serialized_data, leading to unsafe dereferences later.
> > >>
> > >> Validate that args->serialized_data is non-zero before calling
> > >> phys_to_virt().
> > >>
> > >> Fixes: b3749f174d68 ("mm: memfd_luo: allow preserving memfd")
> > >> Signed-off-by: Tarun Sahu <tarunsahu@google.com>
> > >> ---
> > >> mm/memfd_luo.c | 10 ++++++----
> > >> 1 file changed, 6 insertions(+), 4 deletions(-)
> > >>
> > >> diff --git a/mm/memfd_luo.c b/mm/memfd_luo.c
> > >> index 59de210bee5f..10f3983b0060 100644
> > >> --- a/mm/memfd_luo.c
> > >> +++ b/mm/memfd_luo.c
> > >> @@ -397,10 +397,11 @@ static void memfd_luo_finish(struct liveupdate_file_op_args *args)
> > >> if (args->retrieve_status)
> > >> return;
> > >>
> > >> - ser = phys_to_virt(args->serialized_data);
> > >> - if (!ser)
> > >> + if (!args->serialized_data)
> > >
> > > We really should make args->serialized_data a KHOSER_PTR
> >
> > Hmm, that would also be a good idea. I suppose then it would be a better
> > to directly convert to using KHOSER_PTR() instead of this patch?
>
> Makes sense.
I think we should systematically cover all phys_to_virt conversions
and add KOSHER_PTR() , instead of an ad-hoc approach of adding it as we
go. So, let's take this patch and do a series where we properly convert
everything and provide guidance for others to use going forward.
Pasha
>
> > --
> > Regards,
> > Pratyush Yadav
>
> --
> Sincerely yours,
> Mike.
next prev parent reply other threads:[~2026-06-11 18:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 10:30 [PATCH] mm/memfd_luo: validate serialized_data before conversion Tarun Sahu
2026-06-11 12:32 ` Pratyush Yadav
2026-06-11 12:40 ` Mike Rapoport
2026-06-11 13:37 ` Pratyush Yadav
2026-06-11 14:28 ` Mike Rapoport
2026-06-11 18:11 ` Pasha Tatashin [this message]
2026-06-11 18:11 ` Pasha Tatashin
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=air5ho0LOIEKVzRG@plex \
--to=pasha.tatashin@soleen.com \
--cc=akpm@linux-foundation.org \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pratyush@kernel.org \
--cc=rppt@kernel.org \
--cc=tarunsahu@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox