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-next>] [day] [month] [year] [list]
Message-Id: <20250811095330.1573939-1-liuqiqi@kylinos.cn>
Date: Mon, 11 Aug 2025 17:53:30 +0800
From: liuqiqi@...inos.cn
To: gregkh@...uxfoundation.org
Cc: cve@...nel.org,
	linux-cve-announce@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	liuqiqi <liuqiqi@...inos.cn>
Subject: mm:fix duplicate accounting of free pages in should_reclaim_retry()

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@...inos.cn>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ