aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/events/uprobes.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2013-10-13 15:18:38 -0400
committerOleg Nesterov <oleg@redhat.com>2013-10-29 13:02:51 -0400
commitaf0d95af79773f7637107cd3871aaabcb425f15a (patch)
tree0d71695828416dd2bf157dccd608434bdffa8bbf /kernel/events/uprobes.c
parent6441ec8b7c108b72789d120562b9f1d976e4aaaf (diff)
uprobes: Teach __create_xol_area() to accept the predefined vaddr
Currently xol_add_vma() uses get_unmapped_area() for area->vaddr, but the next patches need to use the fixed address. So this patch adds the new "vaddr" argument to __create_xol_area() which should be used as area->vaddr if it is nonzero. xol_add_vma() doesn't bother to verify that the predefined addr is not used, insert_vm_struct() should fail if find_vma_links() detects the overlap with the existing vma. Also, __create_xol_area() doesn't need __GFP_ZERO to allocate area. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Diffstat (limited to 'kernel/events/uprobes.c')
-rw-r--r--kernel/events/uprobes.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index ad17d813e73e..7d12a45842a7 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1104,11 +1104,14 @@ static int xol_add_vma(struct mm_struct *mm, struct xol_area *area)
1104 if (mm->uprobes_state.xol_area) 1104 if (mm->uprobes_state.xol_area)
1105 goto fail; 1105 goto fail;
1106 1106
1107 /* Try to map as high as possible, this is only a hint. */ 1107 if (!area->vaddr) {
1108 area->vaddr = get_unmapped_area(NULL, TASK_SIZE - PAGE_SIZE, PAGE_SIZE, 0, 0); 1108 /* Try to map as high as possible, this is only a hint. */
1109 if (area->vaddr & ~PAGE_MASK) { 1109 area->vaddr = get_unmapped_area(NULL, TASK_SIZE - PAGE_SIZE,
1110 ret = area->vaddr; 1110 PAGE_SIZE, 0, 0);
1111 goto fail; 1111 if (area->vaddr & ~PAGE_MASK) {
1112 ret = area->vaddr;
1113 goto fail;
1114 }
1112 } 1115 }
1113 1116
1114 ret = install_special_mapping(mm, area->vaddr, PAGE_SIZE, 1117 ret = install_special_mapping(mm, area->vaddr, PAGE_SIZE,
@@ -1124,13 +1127,13 @@ static int xol_add_vma(struct mm_struct *mm, struct xol_area *area)
1124 return ret; 1127 return ret;
1125} 1128}
1126 1129
1127static struct xol_area *__create_xol_area(void) 1130static struct xol_area *__create_xol_area(unsigned long vaddr)
1128{ 1131{
1129 struct mm_struct *mm = current->mm; 1132 struct mm_struct *mm = current->mm;
1130 uprobe_opcode_t insn = UPROBE_SWBP_INSN; 1133 uprobe_opcode_t insn = UPROBE_SWBP_INSN;
1131 struct xol_area *area; 1134 struct xol_area *area;
1132 1135
1133 area = kzalloc(sizeof(*area), GFP_KERNEL); 1136 area = kmalloc(sizeof(*area), GFP_KERNEL);
1134 if (unlikely(!area)) 1137 if (unlikely(!area))
1135 goto out; 1138 goto out;
1136 1139
@@ -1142,6 +1145,7 @@ static struct xol_area *__create_xol_area(void)
1142 if (!area->page) 1145 if (!area->page)
1143 goto free_bitmap; 1146 goto free_bitmap;
1144 1147
1148 area->vaddr = vaddr;
1145 init_waitqueue_head(&area->wq); 1149 init_waitqueue_head(&area->wq);
1146 /* Reserve the 1st slot for get_trampoline_vaddr() */ 1150 /* Reserve the 1st slot for get_trampoline_vaddr() */
1147 set_bit(0, area->bitmap); 1151 set_bit(0, area->bitmap);
@@ -1172,7 +1176,7 @@ static struct xol_area *get_xol_area(void)
1172 struct xol_area *area; 1176 struct xol_area *area;
1173 1177
1174 if (!mm->uprobes_state.xol_area) 1178 if (!mm->uprobes_state.xol_area)
1175 __create_xol_area(); 1179 __create_xol_area(0);
1176 1180
1177 area = mm->uprobes_state.xol_area; 1181 area = mm->uprobes_state.xol_area;
1178 smp_read_barrier_depends(); /* pairs with wmb in xol_add_vma() */ 1182 smp_read_barrier_depends(); /* pairs with wmb in xol_add_vma() */