diff options
Diffstat (limited to 'arch/arm/kernel/traps.c')
-rw-r--r-- | arch/arm/kernel/traps.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c index baa09601a64e..66e5a0516f23 100644 --- a/arch/arm/kernel/traps.c +++ b/arch/arm/kernel/traps.c | |||
@@ -483,29 +483,33 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs) | |||
483 | unsigned long addr = regs->ARM_r2; | 483 | unsigned long addr = regs->ARM_r2; |
484 | struct mm_struct *mm = current->mm; | 484 | struct mm_struct *mm = current->mm; |
485 | pgd_t *pgd; pmd_t *pmd; pte_t *pte; | 485 | pgd_t *pgd; pmd_t *pmd; pte_t *pte; |
486 | spinlock_t *ptl; | ||
486 | 487 | ||
487 | regs->ARM_cpsr &= ~PSR_C_BIT; | 488 | regs->ARM_cpsr &= ~PSR_C_BIT; |
488 | spin_lock(&mm->page_table_lock); | 489 | down_read(&mm->mmap_sem); |
489 | pgd = pgd_offset(mm, addr); | 490 | pgd = pgd_offset(mm, addr); |
490 | if (!pgd_present(*pgd)) | 491 | if (!pgd_present(*pgd)) |
491 | goto bad_access; | 492 | goto bad_access; |
492 | pmd = pmd_offset(pgd, addr); | 493 | pmd = pmd_offset(pgd, addr); |
493 | if (!pmd_present(*pmd)) | 494 | if (!pmd_present(*pmd)) |
494 | goto bad_access; | 495 | goto bad_access; |
495 | pte = pte_offset_map(pmd, addr); | 496 | pte = pte_offset_map_lock(mm, pmd, addr, &ptl); |
496 | if (!pte_present(*pte) || !pte_write(*pte)) | 497 | if (!pte_present(*pte) || !pte_write(*pte)) { |
498 | pte_unmap_unlock(pte, ptl); | ||
497 | goto bad_access; | 499 | goto bad_access; |
500 | } | ||
498 | val = *(unsigned long *)addr; | 501 | val = *(unsigned long *)addr; |
499 | val -= regs->ARM_r0; | 502 | val -= regs->ARM_r0; |
500 | if (val == 0) { | 503 | if (val == 0) { |
501 | *(unsigned long *)addr = regs->ARM_r1; | 504 | *(unsigned long *)addr = regs->ARM_r1; |
502 | regs->ARM_cpsr |= PSR_C_BIT; | 505 | regs->ARM_cpsr |= PSR_C_BIT; |
503 | } | 506 | } |
504 | spin_unlock(&mm->page_table_lock); | 507 | pte_unmap_unlock(pte, ptl); |
508 | up_read(&mm->mmap_sem); | ||
505 | return val; | 509 | return val; |
506 | 510 | ||
507 | bad_access: | 511 | bad_access: |
508 | spin_unlock(&mm->page_table_lock); | 512 | up_read(&mm->mmap_sem); |
509 | /* simulate a write access fault */ | 513 | /* simulate a write access fault */ |
510 | do_DataAbort(addr, 15 + (1 << 11), regs); | 514 | do_DataAbort(addr, 15 + (1 << 11), regs); |
511 | return -1; | 515 | return -1; |