Skip to contentSkip to conversation

mm: thp: fix a double unlock bug

PATCH In review Dan Carpenter 3 participants 4 messages Jun 1, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: thp: fix a double unlock bug

We're supposed to be holding the "vmf->ptl" spin_lock when we goto out_map. The lock is dropped after if finishes cleaning up.

Fixes 9aff7b33c74a ("mm: thp: refactor NUMA fault handling")
---
 mm/huge_memory.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
mm/huge_memory.c +1 -3
index e353bbc6cee3..caa0148f15bb 100644
@@ -1465,10 +1465,8 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf)
 
 	pmd = pmd_modify(oldpmd, vma->vm_page_prot);
 	page = vm_normal_page_pmd(vma, haddr, pmd);
-	if (!page) {
-		spin_unlock(vmf->ptl);
+	if (!page)
 		goto out_map;
-	}
 
 	/* See similar comment in do_numa_page for explanation */
 	if (!was_writable)
Signature · 1 line
2.30.2
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Dan Carpenter

We're supposed to be holding the "vmf->ptl" spin_lock when we goto out_map. The lock is dropped after if finishes cleaning up.

Fixes 9aff7b33c74a ("mm: thp: refactor NUMA fault handling")

Ouch.

However, that git commit is not stable. Instead of Fixes: I would suggest renaming the patch to "mm: thp: refactor NUMA fault handling -fix" and replacing Fixes with "This patch is a fix to the mmotm patch mm-thp-refactor-numa-fault-handling.patch". Andrew usually slots that into the correct place in his quilt series and collapses the fixes before sending to Linus which works better with bisection.

Signature · 2 lines
Mel Gorman
SUSE Labs
#2 lore raw
Quoted 9 lines · Mel Gorman
Quoted 5 lines · Dan Carpenter

We're supposed to be holding the "vmf->ptl" spin_lock when we goto out_map. The lock is dropped after if finishes cleaning up.

Fixes 9aff7b33c74a ("mm: thp: refactor NUMA fault handling")

Ouch.

Quoted 8 lines

However, that git commit is not stable. Instead of Fixes: I would suggest renaming the patch to "mm: thp: refactor NUMA fault handling -fix" and replacing Fixes with "This patch is a fix to the mmotm patch mm-thp-refactor-numa-fault-handling.patch". Andrew usually slots that into the correct place in his quilt series and collapses the fixes before sending to Linus which works better with bisection.

I know that these normally get folded in, but I assumed that Andrew would want the Fixes tag so that he could fold them in automatically using a mutt alias. #OneClickShopping

regards,
dan carpenter

#3 lore raw
In reply to Dan Carpenter
Quoted 6 lines · Dan Carpenter

We're supposed to be holding the "vmf->ptl" spin_lock when we goto out_map. The lock is dropped after if finishes cleaning up.

Fixes 9aff7b33c74a ("mm: thp: refactor NUMA fault handling")

Thanks for catching this. Acked-by: Yang Shi <[email protected]>

Quoted 23 lines
---
 mm/huge_memory.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
mm/huge_memory.c +1 -4
index e353bbc6cee3..caa0148f15bb 100644
@@ -1465,10 +1465,8 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf)
 
        pmd = pmd_modify(oldpmd, vma->vm_page_prot);
        page = vm_normal_page_pmd(vma, haddr, pmd);
-       if (!page) {
-               spin_unlock(vmf->ptl);
+       if (!page)
                goto out_map;
-       }
 
        /* See similar comment in do_numa_page for explanation */
        if (!was_writable)
--

2.30.2