aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/uprobes.h2
-rw-r--r--kernel/events/uprobes.c20
2 files changed, 10 insertions, 12 deletions
diff --git a/include/linux/uprobes.h b/include/linux/uprobes.h
index 30297f95c8af..6d4fe79a1a6a 100644
--- a/include/linux/uprobes.h
+++ b/include/linux/uprobes.h
@@ -102,7 +102,7 @@ struct uprobes_state {
102}; 102};
103 103
104extern int __weak set_swbp(struct arch_uprobe *aup, struct mm_struct *mm, unsigned long vaddr); 104extern int __weak set_swbp(struct arch_uprobe *aup, struct mm_struct *mm, unsigned long vaddr);
105extern int __weak set_orig_insn(struct arch_uprobe *aup, struct mm_struct *mm, unsigned long vaddr, bool verify); 105extern int __weak set_orig_insn(struct arch_uprobe *aup, struct mm_struct *mm, unsigned long vaddr);
106extern bool __weak is_swbp_insn(uprobe_opcode_t *insn); 106extern bool __weak is_swbp_insn(uprobe_opcode_t *insn);
107extern int uprobe_register(struct inode *inode, loff_t offset, struct uprobe_consumer *uc); 107extern int uprobe_register(struct inode *inode, loff_t offset, struct uprobe_consumer *uc);
108extern void uprobe_unregister(struct inode *inode, loff_t offset, struct uprobe_consumer *uc); 108extern void uprobe_unregister(struct inode *inode, loff_t offset, struct uprobe_consumer *uc);
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 610e1c8050cf..1666632e6edf 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -345,24 +345,22 @@ int __weak set_swbp(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned
345 * @mm: the probed process address space. 345 * @mm: the probed process address space.
346 * @auprobe: arch specific probepoint information. 346 * @auprobe: arch specific probepoint information.
347 * @vaddr: the virtual address to insert the opcode. 347 * @vaddr: the virtual address to insert the opcode.
348 * @verify: if true, verify existance of breakpoint instruction.
349 * 348 *
350 * For mm @mm, restore the original opcode (opcode) at @vaddr. 349 * For mm @mm, restore the original opcode (opcode) at @vaddr.
351 * Return 0 (success) or a negative errno. 350 * Return 0 (success) or a negative errno.
352 */ 351 */
353int __weak 352int __weak
354set_orig_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned long vaddr, bool verify) 353set_orig_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned long vaddr)
355{ 354{
356 if (verify) { 355 int result;
357 int result; 356
357 result = is_swbp_at_addr(mm, vaddr);
358 if (!result)
359 return -EINVAL;
358 360
359 result = is_swbp_at_addr(mm, vaddr); 361 if (result != 1)
360 if (!result) 362 return result;
361 return -EINVAL;
362 363
363 if (result != 1)
364 return result;
365 }
366 return write_opcode(auprobe, mm, vaddr, *(uprobe_opcode_t *)auprobe->insn); 364 return write_opcode(auprobe, mm, vaddr, *(uprobe_opcode_t *)auprobe->insn);
367} 365}
368 366
@@ -697,7 +695,7 @@ install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm,
697static void 695static void
698remove_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, unsigned long vaddr) 696remove_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, unsigned long vaddr)
699{ 697{
700 set_orig_insn(&uprobe->arch, mm, vaddr, true); 698 set_orig_insn(&uprobe->arch, mm, vaddr);
701} 699}
702 700
703/* 701/*