[PATCH 4/X] uprobes: xol_add_vma: misc cleanups
From: Oleg Nesterov
Date: Sat Oct 15 2011 - 15:05:53 EST
1. get_task_mm(current)/mmput is not needed, we can use ->mm directly.
It can't be NULL or use_mm'ed(), otherwise we are buggy anyway.
2. use IS_ERR_VALUE() after do_mmap_pgoff().
3. No need to read vma->vm_start, it must be equal to addr returned
by do_mmap_pgoff().
4. No need to pass vmas => &vma to get_user_pages().
---
kernel/uprobes.c | 13 +++++--------
1 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/kernel/uprobes.c b/kernel/uprobes.c
index 6fe2b20..5c2554c 100644
--- a/kernel/uprobes.c
+++ b/kernel/uprobes.c
@@ -1051,9 +1051,7 @@ static int xol_add_vma(struct uprobes_xol_area *area)
unsigned long addr;
int ret;
- mm = get_task_mm(current);
- if (!mm)
- return -ESRCH;
+ mm = current->mm;
down_write(&mm->mmap_sem);
ret = -EALREADY;
@@ -1076,24 +1074,23 @@ static int xol_add_vma(struct uprobes_xol_area *area)
addr = do_mmap_pgoff(NULL, addr, PAGE_SIZE, PROT_EXEC, MAP_PRIVATE, 0);
revert_creds(curr_cred);
- if (addr & ~PAGE_MASK)
+ if (IS_ERR_VALUE(addr))
goto fail;
vma = find_vma(mm, addr);
/* Don't expand vma on mremap(). */
vma->vm_flags |= VM_DONTEXPAND | VM_DONTCOPY;
- area->vaddr = vma->vm_start;
- if (get_user_pages(current, mm, area->vaddr, 1, 1, 1, &area->page,
- &vma) != 1) {
+ if (get_user_pages(current, mm, addr, 1, 1, 1,
+ &area->page, NULL) != 1) {
do_munmap(mm, addr, PAGE_SIZE);
goto fail;
}
+ area->vaddr = addr;
mm->uprobes_xol_area = area;
ret = 0;
fail:
up_write(&mm->mmap_sem);
- mmput(mm);
return ret;
}
--
1.5.5.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/