* CVE-2024-57884 patch review feedback (https://lore.kernel.org/linux-cve-announce/2025011510-CVE-2024-57884-4cf8@gregkh/#R)
[not found] <2025011510-CVE-2024-57884-4cf8@gregkh>
@ 2025-08-07 12:54 ` liuqiqi
2025-08-07 13:05 ` liuqiqi
2025-08-11 9:53 ` mm:fix duplicate accounting of free pages in should_reclaim_retry() liuqiqi
2 siblings, 0 replies; 5+ messages in thread
From: liuqiqi @ 2025-08-07 12:54 UTC (permalink / raw)
To: gregkh; +Cc: cve, linux-cve-announce, linux-kernel, liuqiqi
if (cpusets_enabled() &&
(alloc_flags & ALLOC_CPUSET) &&
!__cpuset_zone_allowed(zone, gfp_mask))
continue;
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)
{
struct zone *zone;
struct zoneref *z;
/*
* Make sure at least one zone would pass __compaction_suitable if we continue
* retrying the reclaim.
*/
for_each_zone_zonelist_nodemask(zone, z, ac->zonelist,
ac->highest_zoneidx, ac->nodemask) {
unsigned long available;
/*
* Do not consider all the reclaimable memory because we do not
* want to trash just for a single high order allocation which
* is even not guaranteed to appear even if __compaction_suitable
* is happy about the watermark check.
*/
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
* CVE-2024-57884 patch review feedback (https://lore.kernel.org/linux-cve-announce/2025011510-CVE-2024-57884-4cf8@gregkh/#R)
[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
2025-08-11 9:53 ` mm:fix duplicate accounting of free pages in should_reclaim_retry() liuqiqi
2 siblings, 1 reply; 5+ messages in thread
From: liuqiqi @ 2025-08-07 13:05 UTC (permalink / raw)
To: gregkh; +Cc: cve, linux-cve-announce, linux-kernel, liuqiqi
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: CVE-2024-57884 patch review feedback (https://lore.kernel.org/linux-cve-announce/2025011510-CVE-2024-57884-4cf8@gregkh/#R)
2025-08-07 13:05 ` liuqiqi
@ 2025-08-07 14:24 ` Greg KH
0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2025-08-07 14:24 UTC (permalink / raw)
To: liuqiqi; +Cc: cve, linux-cve-announce, linux-kernel
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* mm:fix duplicate accounting of free pages in should_reclaim_retry()
[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-11 9:53 ` liuqiqi
2025-08-11 11:24 ` Greg KH
2 siblings, 1 reply; 5+ messages in thread
From: liuqiqi @ 2025-08-11 9:53 UTC (permalink / raw)
To: gregkh; +Cc: cve, linux-cve-announce, linux-kernel, liuqiqi
In the zone_reclaimable_pages() function, if the page counts for NR_ZONE_INACTIVE_FILE,
NR_ZONE_ACTIVE_FILE, NR_ZONE_INACTIVE_ANON, and NR_ZONE_ACTIVE_ANON are all zero,
the function returns the number of free pages as the result.
In this case, when should_reclaim_retry() calculates reclaimable pages,
it will inadvertently double-count the free pages in its accounting.
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 34410d24dc15..a9aaefdba7a2 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -393,14 +393,7 @@ unsigned long zone_reclaimable_pages(struct zone *zone)
if (can_reclaim_anon_pages(NULL, zone_to_nid(zone), NULL))
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;
}
@@ -6417,7 +6410,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>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: mm:fix duplicate accounting of free pages in should_reclaim_retry()
2025-08-11 9:53 ` mm:fix duplicate accounting of free pages in should_reclaim_retry() liuqiqi
@ 2025-08-11 11:24 ` Greg KH
0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2025-08-11 11:24 UTC (permalink / raw)
To: liuqiqi; +Cc: cve, linux-cve-announce, linux-kernel
On Mon, Aug 11, 2025 at 05:53:30PM +0800, liuqiqi@kylinos.cn wrote:
> In the zone_reclaimable_pages() function, if the page counts for NR_ZONE_INACTIVE_FILE,
> NR_ZONE_ACTIVE_FILE, NR_ZONE_INACTIVE_ANON, and NR_ZONE_ACTIVE_ANON are all zero,
> the function returns the number of free pages as the result.
>
> In this case, when should_reclaim_retry() calculates reclaimable pages,
> it will inadvertently double-count the free pages in its accounting.
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 34410d24dc15..a9aaefdba7a2 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -393,14 +393,7 @@ unsigned long zone_reclaimable_pages(struct zone *zone)
> if (can_reclaim_anon_pages(NULL, zone_to_nid(zone), NULL))
> 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;
> }
>
> @@ -6417,7 +6410,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>
>
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him
a patch that has triggered this response. He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created. Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.
You are receiving this message because of the following common error(s)
as indicated below:
- Your patch does not have a Signed-off-by: line. Please read the
kernel file, Documentation/process/submitting-patches.rst and resend
it after adding that line. Note, the line needs to be in the body of
the email, before the patch, not at the bottom of the patch or in the
email signature.
- You did not specify a description of why the patch is needed, or
possibly, any description at all, in the email body. Please read the
section entitled "The canonical patch format" in the kernel file,
Documentation/process/submitting-patches.rst for what is needed in
order to properly describe the change.
- You did not submit this patch to the proper subsystem and maintainers.
- You did not write a descriptive Subject: for the patch, allowing Greg,
and everyone else, to know what this patch is all about. Please read
the section entitled "The canonical patch format" in the kernel file,
Documentation/process/submitting-patches.rst for what a proper
Subject: line should look like.
- It looks like you did not use your "real" name for the patch on either
the Signed-off-by: line, or the From: line (both of which have to
match). Please read the kernel file,
Documentation/process/submitting-patches.rst for how to do this
correctly.
If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.
thanks,
greg k-h's patch email bot
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-08-11 11:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[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
2025-08-11 9:53 ` mm:fix duplicate accounting of free pages in should_reclaim_retry() liuqiqi
2025-08-11 11:24 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).