linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2.5.66-mm2] Fix page_convert_anon locking issues
@ 2003-04-02 17:13 Dave McCracken
  2003-04-02 21:29 ` Andrew Morton
  0 siblings, 1 reply; 20+ messages in thread
From: Dave McCracken @ 2003-04-02 17:13 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Linux Memory Management, Linux Kernel

[-- Attachment #1: Type: text/plain, Size: 445 bytes --]


I came up with a scheme for accessing the page tables in page_convert_anon
that should work without requiring locks.  Hugh has looked at it and agrees
it addresses the problems he found.  Anyway, here's the patch.

Dave McCracken

======================================================================
Dave McCracken          IBM Linux Base Kernel Team      1-512-838-3059
dmccr@us.ibm.com                                        T/L   678-3059

[-- Attachment #2: objlock-2.5.66-mm2-1.diff --]
[-- Type: text/plain, Size: 1116 bytes --]

--- 2.5.66-mm2/./mm/rmap.c	2003-04-01 11:23:35.000000000 -0600
+++ 2.5.66-mm2-fix/./mm/rmap.c	2003-04-01 11:30:21.000000000 -0600
@@ -95,7 +95,9 @@ find_pte(struct vm_area_struct *vma, str
 {
 	struct mm_struct *mm = vma->vm_mm;
 	pgd_t *pgd;
+	pgd_t pgdval;
 	pmd_t *pmd;
+	pmd_t pmdval;
 	pte_t *pte;
 	unsigned long loffset;
 	unsigned long address;
@@ -106,17 +108,27 @@ find_pte(struct vm_area_struct *vma, str
 		goto out;
 
 	pgd = pgd_offset(mm, address);
-	if (!pgd_present(*pgd))
+	pgdval = *pgd;
+	if (!pgd_present(pgdval))
 		goto out;
 
-	pmd = pmd_offset(pgd, address);
-	if (!pmd_present(*pmd))
+	pmd = pmd_offset(&pgdval, address);
+	pmdval = *pmd;
+	if (!pmd_present(pmdval))
 		goto out;
 
-	pte = pte_offset_map(pmd, address);
+	/* Double check to make sure the pmd page hasn't been freed */
+	if (!pgd_present(*pgd))
+		goto out;
+
+	pte = pte_offset_map(&pmdval, address);
 	if (!pte_present(*pte))
 		goto out_unmap;
 
+	/* Double check to make sure the pte page hasn't been freed */
+	if (!pmd_present(*pmd))
+		goto out_unmap;
+
 	if (page_to_pfn(page) != pte_pfn(*pte))
 		goto out_unmap;
 

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2003-04-03 21:01 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-02 17:13 [PATCH 2.5.66-mm2] Fix page_convert_anon locking issues Dave McCracken
2003-04-02 21:29 ` Andrew Morton
2003-04-02 21:56   ` Dave McCracken
2003-04-02 23:09     ` Andrew Morton
2003-04-02 23:23       ` Dave McCracken
2003-04-02 23:38         ` Andrew Morton
2003-04-02 23:42           ` Dave McCracken
2003-04-02 23:52             ` Andrew Morton
2003-04-02 23:58               ` Dave McCracken
2003-04-03 14:49                 ` Dave McCracken
2003-04-03 15:38                   ` Hugh Dickins
2003-04-03 16:00                     ` Dave McCracken
2003-04-03 16:33                       ` Hugh Dickins
2003-04-03 16:39                         ` Dave McCracken
2003-04-03 20:00                   ` Andrew Morton
2003-04-03 20:06                   ` Andrew Morton
2003-04-03 20:56                     ` Andrew Morton
2003-04-03 21:01                       ` Dave McCracken
2003-04-02 23:59             ` Hugh Dickins
2003-04-03  0:06         ` Hugh Dickins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox