powerpc/mm: fix mmap_lock bad unlock
Subsystems (2)
PATCH 1/1 powerpc/mm: fix mmap_lock bad unlock
When page fault is tried holding the per VMA lock, bad_access_pkey() and bad_access() should not be called because it is assuming the mmap_lock is held.
In the case a bad access is detected, fall back to the default path, grabbing the mmap_lock to handle the fault and report the error.
--- arch/powerpc/mm/fault.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
arch/powerpc/mm/fault.c +2 -6
@@ -479,17 +479,13 @@ static int ___do_page_fault(struct pt_regs *regs, unsigned long address,if (unlikely (access_pkey_error (is_write, is_exec, (error_code &DSISR_KEYFAULT ), vma))) { -int rc =bad_access_pkey (regs, address, vma); -vma_end_read (vma); -return rc; + goto lock_mmap; }if (unlikely (access_error (is_write, is_exec, vma))) { -int rc =bad_access (regs, address); -vma_end_read (vma); -return rc; + goto lock_mmap; } fault =handle_mm_fault (vma, address, flags |FAULT_FLAG_VMA_LOCK , regs);
Signature · 1 line
2.39.2
Quoted 29 lines · Laurent Dufour
When page fault is tried holding the per VMA lock,
bad_access_pkey()andbad_access()should not be called because it is assuming themmap_lockis held.
In the case a bad access is detected, fall back to the default path, grabbing themmap_lockto handle the fault and report the error.Fixes 169db3bb4609 ("powerc/mm: try VMA lock-based page fault handling first")Reported-by Sachin Sant <[email protected]>Cc Suren Baghdasaryan <[email protected]>Signed-off-by Laurent Dufour <[email protected]>--- arch/powerpc/mm/fault.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)arch/powerpc/mm/fault.c +1
-3@@ -479,17 +479,13 @@ static int ___do_page_fault(struct pt_regs *regs, unsigned long address,if (unlikely (access_pkey_error (is_write, is_exec, (error_code &DSISR_KEYFAULT ), vma))) { -int rc =bad_access_pkey (regs, address, vma); -vma_end_read (vma); -return rc; + goto lock_mmap; }
arch/powerpc/mm/fault.c static int ___do_page_fault(struct pt_regs *regs, unsigned long address, · line 491
Quoted 10 lines
arch/powerpc/mm/fault.c +1
-3if (unlikely (access_error (is_write, is_exec, vma))) { -int rc =bad_access (regs, address); -vma_end_read (vma); -return rc; + goto lock_mmap; } fault =handle_mm_fault (vma, address, flags |FAULT_FLAG_VMA_LOCK , regs);
IIUC, that commit is neither upstream not in mm-stable -- it's unstable. Maybe raise that as a review comment in reply to the original patch, so we can easily connect the dots and squash it into the original, problematic patch that is still under review.
Signature · 3 lines
Thanks, David / dhildenb
Quoted 38 lines · David Hildenbrand
Quoted 37 lines · Laurent Dufour
When page fault is tried holding the per VMA lock,
bad_access_pkey()andbad_access()should not be called because it is assuming themmap_lockis held.
In the case a bad access is detected, fall back to the default path, grabbing themmap_lockto handle the fault and report the error.Fixes 169db3bb4609 ("powerc/mm: try VMA lock-based page fault handlingfirst")
Reported-by Sachin Sant <[email protected]>Link:
https://lore.kernel.org/linux-mm/[email protected]Cc Suren Baghdasaryan <[email protected]>Signed-off-by Laurent Dufour <[email protected]>---
arch/powerpc/mm/fault.c| 8 ++------1 file changed, 2 insertions(+), 6 deletions(-)arch/powerpc/mm/fault.c +2
-6@@ -479,17 +479,13 @@ static int ___do_page_fault(struct pt_regs *regs,unsigned long address, if (unlikely(access_pkey_error(is_write, is_exec, (error_code & DSISR_KEYFAULT), vma))) { - int rc = bad_access_pkey(regs, address, vma); - vma_end_read(vma); - return rc; + goto lock_mmap; } if (unlikely(access_error(is_write, is_exec, vma))) { - int rc = bad_access(regs, address); - vma_end_read(vma); - return rc; + goto lock_mmap;
Quoted 9 lines
Quoted 3 lines
arch/powerpc/mm/fault.c +0
-0}fault =
handle_mm_fault(vma, address, flags | FAULT_FLAG_VMA_LOCK, regs);IIUC, that commit is neither upstream not in mm-stable -- it's unstable. Maybe raise that as a review comment in reply to the original patch, so we can easily connect the dots and squash it into the original, problematic patch that is still under review.
Oh yes, I missed that. I'll reply to the Suren's thread.
Thanks,
Laurent.
Quoted 49 lines · Laurent Dufour
Quoted 38 lines · David Hildenbrand
Quoted 37 lines · Laurent Dufour
When page fault is tried holding the per VMA lock,
bad_access_pkey()andbad_access()should not be called because it is assuming themmap_lockis held.
In the case a bad access is detected, fall back to the default path, grabbing themmap_lockto handle the fault and report the error.Fixes 169db3bb4609 ("powerc/mm: try VMA lock-based page fault handlingfirst")
Reported-by Sachin Sant <[email protected]>Link:
https://lore.kernel.org/linux-mm/[email protected]Cc Suren Baghdasaryan <[email protected]>Signed-off-by Laurent Dufour <[email protected]>--- arch/powerpc/mm/fault.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)arch/powerpc/mm/fault.c +2
-6@@ -479,17 +479,13 @@ static int ___do_page_fault(struct pt_regs *regs, unsigned long address, if (unlikely(access_pkey_error(is_write, is_exec, (error_code & DSISR_KEYFAULT), vma))) { - int rc = bad_access_pkey(regs, address, vma); - vma_end_read(vma); -return rc; + goto lock_mmap; }if (unlikely (access_error (is_write, is_exec, vma))) { -int rc =bad_access (regs, address); -vma_end_read (vma); -return rc; + goto lock_mmap;Quoted 9 lines
arch/powerpc/mm/fault.c static int ___do_page_fault(struct pt_regs *regs, · line 490
Quoted 3 lines
arch/powerpc/mm/fault.c +0
-0} fault =handle_mm_fault (vma, address, flags |FAULT_FLAG_VMA_LOCK , regs);IIUC, that commit is neither upstream not in mm-stable -- it's unstable. Maybe raise that as a review comment in reply to the original patch, so we can easily connect the dots and squash it into the original, problematic patch that is still under review.
Quoted 1 line
Oh yes, I missed that. I'll reply to the Suren's thread.
Thanks Laurent! Seems simple enough to patch the original change.
Quoted 3 lines
Thanks,
Laurent.