]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ARM: Ensure do_cache_op takes mmap_sem
authorRussell King <rmk+kernel@arm.linux.org.uk>
Mon, 28 Sep 2009 10:41:51 +0000 (11:41 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Mon, 28 Sep 2009 17:06:21 +0000 (18:06 +0100)
do_cache_op() uses find_vma() to validate its arguments without holding
any locking.  This means that the VMA could vanish beneath us.  Fix
this by taking a read lock on mmap_sem.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/kernel/traps.c

index 57eb0f6f60053e6fd12fd48113e8a5fdb6b744b8..467b69ed1021b39fb87848b4009edfef9fb9f1d2 100644 (file)
@@ -418,12 +418,14 @@ static int bad_syscall(int n, struct pt_regs *regs)
 static inline void
 do_cache_op(unsigned long start, unsigned long end, int flags)
 {
+       struct mm_struct *mm = current->active_mm;
        struct vm_area_struct *vma;
 
        if (end < start || flags)
                return;
 
-       vma = find_vma(current->active_mm, start);
+       down_read(&mm->mmap_sem);
+       vma = find_vma(mm, start);
        if (vma && vma->vm_start < end) {
                if (start < vma->vm_start)
                        start = vma->vm_start;
@@ -432,6 +434,7 @@ do_cache_op(unsigned long start, unsigned long end, int flags)
 
                flush_cache_user_range(vma, start, end);
        }
+       up_read(&mm->mmap_sem);
 }
 
 /*