From: Greg KH <gregkh@linuxfoundation.org>
To: liuqiqi@kylinos.cn
Cc: cve@kernel.org, linux-cve-announce@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: CVE-2024-57884 patch review feedback (https://lore.kernel.org/linux-cve-announce/2025011510-CVE-2024-57884-4cf8@gregkh/#R)
Date: Thu, 7 Aug 2025 15:24:09 +0100 [thread overview]
Message-ID: <2025080744-buckskin-triumph-2f79@gregkh> (raw)
In-Reply-To: <20250807130515.1445117-1-liuqiqi@kylinos.cn>
On Thu, Aug 07, 2025 at 09:05:15PM +0800, liuqiqi@kylinos.cn wrote:
> CVE-2024-57884 patch fixes mm: vmscan: account for free pages to prevent infinite Loop in throttle_direct_reclaim() modify as follows
> @@ -342,7 +342,14 @@ unsigned long zone_reclaimable_pages(struct zone *zone)
> if (get_nr_swap_pages() > 0)
> nr += zone_page_state_snapshot(zone, NR_ZONE_INACTIVE_ANON) +
> zone_page_state_snapshot(zone, NR_ZONE_ACTIVE_ANON);
> -
> + /*
> + * If there are no reclaimable file-backed or anonymous pages,
> + * ensure zones with sufficient free pages are not skipped.
> + * This prevents zones like DMA32 from being ignored in reclaim
> + * scenarios where they can still help alleviate memory pressure.
> + */
> + if (nr == 0)
> + nr = zone_page_state_snapshot(zone, NR_FREE_PAGES);
> return nr;
> }
> However, should_reclaim_retry() function calls zone_reclaimable_pages to count free pages. When nr is 0, it double-counts NR_FREE_PAGES. This seems to cause inaccurate page statistics, right?
> static inline bool
> should_reclaim_retry(gfp_t gfp_mask, unsigned order,
> struct alloc_context *ac, int alloc_flags,
> bool did_some_progress, int *no_progress_loops)
> {
> ......
>
> available = reclaimable = zone_reclaimable_pages(zone);
> available += zone_page_state_snapshot(zone, NR_FREE_PAGES);
>
> /*
> * Would the allocation succeed if we reclaimed all
> * reclaimable pages?
> */
> wmark = __zone_watermark_ok(zone, order, min_wmark,
> ac->highest_zoneidx, alloc_flags, available);
>
> compaction_zonelist_suitable() function has the same problem.
> bool compaction_zonelist_suitable(struct alloc_context *ac, int order,
> int alloc_flags)
> {
> ......
> available = zone_reclaimable_pages(zone) / order;
> available += zone_page_state_snapshot(zone, NR_FREE_PAGES);
> if (__compaction_suitable(zone, order, min_wmark_pages(zone),
> ac->highest_zoneidx, available))
>
> If this is problematic, can it be modified as follows:
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -6417,7 +6417,7 @@ static bool allow_direct_reclaim(pg_data_t *pgdat)
> return true;
>
> for_each_managed_zone_pgdat(zone, pgdat, i, ZONE_NORMAL) {
> - if (!zone_reclaimable_pages(zone))
> + if (!zone_reclaimable_pages(zone) || !(zone_page_state_snapshot(zone, NR_FREE_PAGES)))
> continue;
>
> Signed-off-by: liuqiqi <liuqiqi@kylinos.cn>
I have no idea what you are asking about or wishing to see change.
Please read the kernel documentation for how to send a proper patch.
thanks,
greg k-h
next prev parent reply other threads:[~2025-08-07 14:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <2025011510-CVE-2024-57884-4cf8@gregkh>
2025-08-07 12:54 ` CVE-2024-57884 patch review feedback (https://lore.kernel.org/linux-cve-announce/2025011510-CVE-2024-57884-4cf8@gregkh/#R) liuqiqi
2025-08-07 13:05 ` liuqiqi
2025-08-07 14:24 ` Greg KH [this message]
2025-08-11 9:53 ` mm:fix duplicate accounting of free pages in should_reclaim_retry() liuqiqi
2025-08-11 11:24 ` Greg KH
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=2025080744-buckskin-triumph-2f79@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=cve@kernel.org \
--cc=linux-cve-announce@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuqiqi@kylinos.cn \
/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