lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <031a9b4b-96aa-49fd-9005-3494f080695c@lucifer.local>
Date: Mon, 10 Nov 2025 22:03:04 +0000
From: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
To: Zi Yan <ziy@...dia.com>
Cc: "Garg, Shivank" <shivankg@....com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        David Hildenbrand <david@...hat.com>,
        Baolin Wang <baolin.wang@...ux.alibaba.com>,
        "Liam R . Howlett" <Liam.Howlett@...cle.com>,
        Nico Pache <npache@...hat.com>, Ryan Roberts <ryan.roberts@....com>,
        Dev Jain <dev.jain@....com>, Barry Song <baohua@...nel.org>,
        Lance Yang <lance.yang@...ux.dev>,
        Steven Rostedt <rostedt@...dmis.org>,
        Masami Hiramatsu <mhiramat@...nel.org>,
        Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
        Zach O'Keefe <zokeefe@...gle.com>, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org,
        Branden Moore <Branden.Moore@....com>
Subject: Re: [PATCH 1/2] mm/khugepaged: do synchronous writeback for
 MADV_COLLAPSE

On Mon, Nov 10, 2025 at 04:56:37PM -0500, Zi Yan wrote:
> On 10 Nov 2025, at 16:16, Lorenzo Stoakes wrote:
>
> > OK ignore the past mail, I have managed to repro this locally and have a
> > fix.
> >
> > Turns out the swap code is doing something quite insane... I will send
> > fix-patches to the series shortly.
> >
> > Meanwhile I attach fix-patch! :)
> >
> > Cheers, Lorenzo
> >
> > ----8<----
> > From c705fd85a806f53017df31e6b072c4bfa839e3a2 Mon Sep 17 00:00:00 2001
> > From: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
> > Date: Mon, 10 Nov 2025 21:11:52 +0000
> > Subject: [PATCH] fix
> >
> > Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
> > ---
> >  include/linux/leafops.h |  4 ++--
> >  mm/swapfile.c           | 12 ++++++++++--
> >  2 files changed, 12 insertions(+), 4 deletions(-)
> >
> > diff --git a/include/linux/leafops.h b/include/linux/leafops.h
> > index a464a7e08c76..c4cd36760ea0 100644
> > --- a/include/linux/leafops.h
> > +++ b/include/linux/leafops.h
> > @@ -56,7 +56,7 @@ static inline softleaf_t softleaf_from_pte(pte_t pte)
> >  {
> >  	softleaf_t arch_entry;
> >
> > -	if (pte_present(pte))
> > +	if (pte_present(pte) || pte_none(pte))
> >  		return softleaf_mk_none();
> >
> >  	pte = pte_swp_clear_flags(pte);
> > @@ -95,7 +95,7 @@ static inline softleaf_t softleaf_from_pmd(pmd_t pmd)
> >  {
> >  	softleaf_t arch_entry;
> >
> > -	if (pmd_present(pmd))
> > +	if (pmd_present(pmd) || pmd_none(pmd))
> >  		return softleaf_mk_none();
> >
> >  	if (pmd_swp_soft_dirty(pmd))
> > diff --git a/mm/swapfile.c b/mm/swapfile.c
> > index fd23d9f7ae10..f0dcf261f652 100644
> > --- a/mm/swapfile.c
> > +++ b/mm/swapfile.c
> > @@ -3202,9 +3202,17 @@ static int claim_swapfile(struct swap_info_struct *si, struct inode *inode)
> >   */
> >  unsigned long generic_max_swapfile_size(void)
> >  {
> > -	const softleaf_t entry = swp_entry(0, ~0UL);
> > +	softleaf_t entry = swp_entry(0, ~0UL);
> > +	const pte_t pte = softleaf_to_pte(entry);
> >
> > -	return swp_offset(softleaf_from_pte(softleaf_to_pte(entry))) + 1;
> > +	/*
> > +	* Since the PTE can be an invalid swap entry (i.e. the none PTE), we do
>
> So softleaf_from_pte() returns softleaf_mk_none() instead and causes the
> issue?

Yup :) fun!

It's kinda crazy that on x86-64 at least we _intentionally_ generate an invalid
swap entry but there we go.

>
> > +	* this manually.
> > +	*/
>
> This comment is not aligned, in case you plan to send this patch as is. :)

Lol ugh, well I've split out this fix with fixes for all other raised points and
plan to send a v3 of that series to make life easier.

There's a bunch of conflicts that arise from the changes so that's easier for
everyone.

>
> > +	entry = __pte_to_swp_entry(pte);
> > +	entry = swp_entry(__swp_type(entry), __swp_offset(entry));
> > +
> > +	return swp_offset(entry) + 1;
> >  }
> >
> >  /* Can be overridden by an architecture for additional checks. */
> > --
> > 2.51.0
>
> This fix looks good to me. Thanks.

Thanks!

>
> Best Regards,
> Yan, Zi

Cheers, Lorenzo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ