[v3,1/3] mm: ptdump should use ptep_get_lockless()

Message ID 20230612151545.3317766-2-ryan.roberts@arm.com
State New
Headers
Series Encapsulate PTE contents from non-arch code |

Commit Message

Ryan Roberts June 12, 2023, 3:15 p.m. UTC
  The page table dumper uses walk_page_range_novma() to walk the page
tables, which does not lock the PTL before calling the pte_entry()
callback. Therefore, the page table dumper's callback must use
ptep_get_lockless() rather than ptep_get() to ensure that the pte it
reads is not torn or otherwise corrupt when racing with writers.

Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
---
 mm/ptdump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/mm/ptdump.c b/mm/ptdump.c
index 8adab455a68b..03c1bdae4a43 100644
--- a/mm/ptdump.c
+++ b/mm/ptdump.c
@@ -119,7 +119,7 @@  static int ptdump_pte_entry(pte_t *pte, unsigned long addr,
 			    unsigned long next, struct mm_walk *walk)
 {
 	struct ptdump_state *st = walk->private;
-	pte_t val = ptep_get(pte);
+	pte_t val = ptep_get_lockless(pte);
 
 	if (st->effective_prot)
 		st->effective_prot(st, 4, pte_val(val));