Skip to content

Commit

Permalink
ARM: Ensure do_cache_op takes mmap_sem
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Russell King committed Sep 28, 2009
1 parent 90140c3 commit aa45ee8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion arch/arm/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

/*
Expand Down

0 comments on commit aa45ee8

Please sign in to comment.