diff options
author | Oleg Nesterov <oleg@redhat.com> | 2012-06-15 11:43:50 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2012-06-16 03:10:47 -0400 |
commit | d9c4a30e82614d43b55893a73f31e7284007ce82 (patch) | |
tree | b877ed2338d27237e40b2587cdf9e6cd56fefe57 /kernel/events | |
parent | eb2bf57bee42c7565032f93adaa211e2c9fcc52c (diff) |
uprobes: Move BUG_ON(UPROBE_SWBP_INSN_SIZE) from write_opcode() to install_breakpoint()
write_opcode() ensures that UPROBE_SWBP_INSN doesn't cross the
page boundary. This looks a bit confusing, the check does not
depend on vaddr and it is enough to do it only once right after
install_breakpoint()->arch_uprobe_analyze_insn().
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Acked-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Anton Arapov <anton@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20120615154350.GA9611@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/events')
-rw-r--r-- | kernel/events/uprobes.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 14c71a2aadad..b9c61bda9029 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c | |||
@@ -210,7 +210,6 @@ static int write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm, | |||
210 | void *vaddr_old, *vaddr_new; | 210 | void *vaddr_old, *vaddr_new; |
211 | struct vm_area_struct *vma; | 211 | struct vm_area_struct *vma; |
212 | struct uprobe *uprobe; | 212 | struct uprobe *uprobe; |
213 | unsigned long pgoff; | ||
214 | int ret; | 213 | int ret; |
215 | retry: | 214 | retry: |
216 | /* Read the page with vaddr into memory */ | 215 | /* Read the page with vaddr into memory */ |
@@ -251,11 +250,7 @@ retry: | |||
251 | vaddr_new = kmap_atomic(new_page); | 250 | vaddr_new = kmap_atomic(new_page); |
252 | 251 | ||
253 | memcpy(vaddr_new, vaddr_old, PAGE_SIZE); | 252 | memcpy(vaddr_new, vaddr_old, PAGE_SIZE); |
254 | 253 | memcpy(vaddr_new + (vaddr & ~PAGE_MASK), &opcode, UPROBE_SWBP_INSN_SIZE); | |
255 | /* poke the new insn in, ASSUMES we don't cross page boundary */ | ||
256 | pgoff = (vaddr & ~PAGE_MASK); | ||
257 | BUG_ON(pgoff + UPROBE_SWBP_INSN_SIZE > PAGE_SIZE); | ||
258 | memcpy(vaddr_new + pgoff, &opcode, UPROBE_SWBP_INSN_SIZE); | ||
259 | 254 | ||
260 | kunmap_atomic(vaddr_new); | 255 | kunmap_atomic(vaddr_new); |
261 | kunmap_atomic(vaddr_old); | 256 | kunmap_atomic(vaddr_old); |
@@ -699,6 +694,10 @@ install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, | |||
699 | if (ret) | 694 | if (ret) |
700 | return ret; | 695 | return ret; |
701 | 696 | ||
697 | /* write_opcode() assumes we don't cross page boundary */ | ||
698 | BUG_ON((uprobe->offset & ~PAGE_MASK) + | ||
699 | UPROBE_SWBP_INSN_SIZE > PAGE_SIZE); | ||
700 | |||
702 | uprobe->flags |= UPROBE_COPY_INSN; | 701 | uprobe->flags |= UPROBE_COPY_INSN; |
703 | } | 702 | } |
704 | 703 | ||