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 for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 30 Oct 2023 14:00:05 -0400
From:   Gregory Price <gourry.memverge@...il.com>
To:     linux-mm@...ck.org
Cc:     akpm@...ux-foundation.org, willy@...radead.org, david@...hat.com,
        vbabka@...e.cz, naoya.horiguchi@...ux.dev,
        linux-kernel@...r.kernel.org,
        Gregory Price <gregory.price@...verge.com>
Subject: [PATCH v2] kpageflags: respect folio head-page flag placement

kpageflags reads page-flags directly from the page, even when the
respective flag is only updated on the headpage of a folio.

Update bitchecks to use PAGEFLAG() interfaces to check folio for the
referenced, dirty, lru, active, and unevictable bits.

Signed-off-by: Gregory Price <gregory.price@...verge.com>
---
 fs/proc/page.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/fs/proc/page.c b/fs/proc/page.c
index 195b077c0fac..1dceecb8018a 100644
--- a/fs/proc/page.c
+++ b/fs/proc/page.c
@@ -111,6 +111,7 @@ u64 stable_page_flags(struct page *page)
 {
 	u64 k;
 	u64 u;
+	struct folio *folio;
 
 	/*
 	 * pseudo flag: KPF_NOPAGE
@@ -119,6 +120,8 @@ u64 stable_page_flags(struct page *page)
 	if (!page)
 		return 1 << KPF_NOPAGE;
 
+	folio = page_folio(page);
+
 	k = page->flags;
 	u = 0;
 
@@ -188,20 +191,31 @@ u64 stable_page_flags(struct page *page)
 		u |= 1 << KPF_SLAB;
 
 	u |= kpf_copy_bit(k, KPF_ERROR,		PG_error);
-	u |= kpf_copy_bit(k, KPF_DIRTY,		PG_dirty);
+
+	if (folio_test_dirty(folio))
+		u |= 1 << KPF_DIRTY;
+
 	u |= kpf_copy_bit(k, KPF_UPTODATE,	PG_uptodate);
 	u |= kpf_copy_bit(k, KPF_WRITEBACK,	PG_writeback);
 
-	u |= kpf_copy_bit(k, KPF_LRU,		PG_lru);
-	u |= kpf_copy_bit(k, KPF_REFERENCED,	PG_referenced);
-	u |= kpf_copy_bit(k, KPF_ACTIVE,	PG_active);
+	if (folio_test_lru(folio))
+		u |= 1 << KPF_LRU;
+
+	if (folio_test_referenced(folio))
+		u |= 1 << KPF_REFERENCED;
+
+	if (folio_test_active(folio))
+		u |= 1 << KPF_ACTIVE;
+
 	u |= kpf_copy_bit(k, KPF_RECLAIM,	PG_reclaim);
 
 	if (PageSwapCache(page))
 		u |= 1 << KPF_SWAPCACHE;
 	u |= kpf_copy_bit(k, KPF_SWAPBACKED,	PG_swapbacked);
 
-	u |= kpf_copy_bit(k, KPF_UNEVICTABLE,	PG_unevictable);
+	if (folio_test_unevictable(folio))
+		u |= 1 << KPF_UNEVICTABLE;
+
 	u |= kpf_copy_bit(k, KPF_MLOCKED,	PG_mlocked);
 
 #ifdef CONFIG_MEMORY_FAILURE
-- 
2.39.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ