Skip to content

Commit f403072

Browse files
oleg-nesterovIngo Molnar
authored andcommitted
uprobes: Don't recheck vma/f_mapping in write_opcode()
write_opcode() rechecks valid_vma() and ->f_mapping, this is pointless. The caller, register_for_each_vma() or uprobe_mmap(), has already done these checks under mmap_sem. To clarify, uprobe_mmap() checks valid_vma() only, but we can rely on build_probe_list(vm_file->f_mapping->host). Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Srikar Dronamraju <srikar.vnet.ibm.com> Cc: Anton Arapov <anton@redhat.com> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Link: http://lkml.kernel.org/r/20120729182212.GA20304@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 35d56ca commit f403072

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

kernel/events/uprobes.c

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -206,33 +206,16 @@ static int write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm,
206206
unsigned long vaddr, uprobe_opcode_t opcode)
207207
{
208208
struct page *old_page, *new_page;
209-
struct address_space *mapping;
210209
void *vaddr_old, *vaddr_new;
211210
struct vm_area_struct *vma;
212-
struct uprobe *uprobe;
213211
int ret;
212+
214213
retry:
215214
/* Read the page with vaddr into memory */
216215
ret = get_user_pages(NULL, mm, vaddr, 1, 0, 0, &old_page, &vma);
217216
if (ret <= 0)
218217
return ret;
219218

220-
ret = -EINVAL;
221-
222-
/*
223-
* We are interested in text pages only. Our pages of interest
224-
* should be mapped for read and execute only. We desist from
225-
* adding probes in write mapped pages since the breakpoints
226-
* might end up in the file copy.
227-
*/
228-
if (!valid_vma(vma, is_swbp_insn(&opcode)))
229-
goto put_out;
230-
231-
uprobe = container_of(auprobe, struct uprobe, arch);
232-
mapping = uprobe->inode->i_mapping;
233-
if (mapping != vma->vm_file->f_mapping)
234-
goto put_out;
235-
236219
ret = -ENOMEM;
237220
new_page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, vaddr);
238221
if (!new_page)

0 commit comments

Comments
 (0)