Commit 5040573e authored by Davidlohr Bueso's avatar Davidlohr Bueso Committed by Linus Torvalds

arc: call find_vma with the mmap_sem held

Performing vma lookups without taking the mm->mmap_sem is asking for
trouble.  While doing the search, the vma in question can be modified or
even removed before returning to the caller.  Take the lock (shared) in
order to avoid races while iterating through the vmacache and/or rbtree.

[akpm@linux-foundation.org: CSE current->active_mm, per Vineet]
Signed-off-by: default avatarDavidlohr Bueso <davidlohr@hp.com>
Acked-by: default avatarVineet Gupta <vgupta@synopsys.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 2ee06468
...@@ -86,12 +86,13 @@ static void show_faulting_vma(unsigned long address, char *buf) ...@@ -86,12 +86,13 @@ static void show_faulting_vma(unsigned long address, char *buf)
unsigned long ino = 0; unsigned long ino = 0;
dev_t dev = 0; dev_t dev = 0;
char *nm = buf; char *nm = buf;
struct mm_struct *active_mm = current->active_mm;
/* can't use print_vma_addr() yet as it doesn't check for /* can't use print_vma_addr() yet as it doesn't check for
* non-inclusive vma * non-inclusive vma
*/ */
down_read(&active_mm->mmap_sem);
vma = find_vma(current->active_mm, address); vma = find_vma(active_mm, address);
/* check against the find_vma( ) behaviour which returns the next VMA /* check against the find_vma( ) behaviour which returns the next VMA
* if the container VMA is not found * if the container VMA is not found
...@@ -110,9 +111,10 @@ static void show_faulting_vma(unsigned long address, char *buf) ...@@ -110,9 +111,10 @@ static void show_faulting_vma(unsigned long address, char *buf)
vma->vm_start < TASK_UNMAPPED_BASE ? vma->vm_start < TASK_UNMAPPED_BASE ?
address : address - vma->vm_start, address : address - vma->vm_start,
nm, vma->vm_start, vma->vm_end); nm, vma->vm_start, vma->vm_end);
} else { } else
pr_info(" @No matching VMA found\n"); pr_info(" @No matching VMA found\n");
}
up_read(&active_mm->mmap_sem);
} }
static void show_ecr_verbose(struct pt_regs *regs) static void show_ecr_verbose(struct pt_regs *regs)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment