diff options
author | Oleg Nesterov <oleg@redhat.com> | 2012-06-15 11:43:55 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2012-06-16 03:10:48 -0400 |
commit | 816c03fbabe64fa09f66fbb64e932081af381415 (patch) | |
tree | 3294289d5f51d7c6eae3ada88602e891c9edef3c /kernel/events | |
parent | 449d0d7c9fb87277175db34c009c70cb348004a8 (diff) |
uprobes: Don't use loff_t for the valid virtual address
loff_t looks confusing when it is used for the virtual address.
Change map_info and install_breakpoint/remove_breakpoint paths
to use "unsigned long".
The patch doesn't change vma_address(), it can't return "long"
because it is used to verify the mapping. But probably this
needs some cleanups too.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Anton Arapov <anton@redhat.com>
Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Acked-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20120615154355.GA9622@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/events')
-rw-r--r-- | kernel/events/uprobes.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 7d5c78f063ae..4df84b76dd48 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c | |||
@@ -664,9 +664,8 @@ static int copy_insn(struct uprobe *uprobe, struct file *filp) | |||
664 | */ | 664 | */ |
665 | static int | 665 | static int |
666 | install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, | 666 | install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, |
667 | struct vm_area_struct *vma, loff_t vaddr) | 667 | struct vm_area_struct *vma, unsigned long vaddr) |
668 | { | 668 | { |
669 | unsigned long addr; | ||
670 | int ret; | 669 | int ret; |
671 | 670 | ||
672 | /* | 671 | /* |
@@ -679,8 +678,6 @@ install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, | |||
679 | if (!uprobe->consumers) | 678 | if (!uprobe->consumers) |
680 | return -EEXIST; | 679 | return -EEXIST; |
681 | 680 | ||
682 | addr = (unsigned long)vaddr; | ||
683 | |||
684 | if (!(uprobe->flags & UPROBE_COPY_INSN)) { | 681 | if (!(uprobe->flags & UPROBE_COPY_INSN)) { |
685 | ret = copy_insn(uprobe, vma->vm_file); | 682 | ret = copy_insn(uprobe, vma->vm_file); |
686 | if (ret) | 683 | if (ret) |
@@ -689,7 +686,7 @@ install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, | |||
689 | if (is_swbp_insn((uprobe_opcode_t *)uprobe->arch.insn)) | 686 | if (is_swbp_insn((uprobe_opcode_t *)uprobe->arch.insn)) |
690 | return -ENOTSUPP; | 687 | return -ENOTSUPP; |
691 | 688 | ||
692 | ret = arch_uprobe_analyze_insn(&uprobe->arch, mm, addr); | 689 | ret = arch_uprobe_analyze_insn(&uprobe->arch, mm, vaddr); |
693 | if (ret) | 690 | if (ret) |
694 | return ret; | 691 | return ret; |
695 | 692 | ||
@@ -709,7 +706,7 @@ install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, | |||
709 | * Hence increment before and decrement on failure. | 706 | * Hence increment before and decrement on failure. |
710 | */ | 707 | */ |
711 | atomic_inc(&mm->uprobes_state.count); | 708 | atomic_inc(&mm->uprobes_state.count); |
712 | ret = set_swbp(&uprobe->arch, mm, addr); | 709 | ret = set_swbp(&uprobe->arch, mm, vaddr); |
713 | if (ret) | 710 | if (ret) |
714 | atomic_dec(&mm->uprobes_state.count); | 711 | atomic_dec(&mm->uprobes_state.count); |
715 | 712 | ||
@@ -717,9 +714,9 @@ install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, | |||
717 | } | 714 | } |
718 | 715 | ||
719 | static void | 716 | static void |
720 | remove_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, loff_t vaddr) | 717 | remove_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, unsigned long vaddr) |
721 | { | 718 | { |
722 | if (!set_orig_insn(&uprobe->arch, mm, (unsigned long)vaddr, true)) | 719 | if (!set_orig_insn(&uprobe->arch, mm, vaddr, true)) |
723 | atomic_dec(&mm->uprobes_state.count); | 720 | atomic_dec(&mm->uprobes_state.count); |
724 | } | 721 | } |
725 | 722 | ||
@@ -743,7 +740,7 @@ static void delete_uprobe(struct uprobe *uprobe) | |||
743 | struct map_info { | 740 | struct map_info { |
744 | struct map_info *next; | 741 | struct map_info *next; |
745 | struct mm_struct *mm; | 742 | struct mm_struct *mm; |
746 | loff_t vaddr; | 743 | unsigned long vaddr; |
747 | }; | 744 | }; |
748 | 745 | ||
749 | static inline struct map_info *free_map_info(struct map_info *info) | 746 | static inline struct map_info *free_map_info(struct map_info *info) |
@@ -837,7 +834,6 @@ static int register_for_each_vma(struct uprobe *uprobe, bool is_register) | |||
837 | while (info) { | 834 | while (info) { |
838 | struct mm_struct *mm = info->mm; | 835 | struct mm_struct *mm = info->mm; |
839 | struct vm_area_struct *vma; | 836 | struct vm_area_struct *vma; |
840 | loff_t vaddr; | ||
841 | 837 | ||
842 | if (err) | 838 | if (err) |
843 | goto free; | 839 | goto free; |
@@ -847,9 +843,8 @@ static int register_for_each_vma(struct uprobe *uprobe, bool is_register) | |||
847 | if (!vma || !valid_vma(vma, is_register)) | 843 | if (!vma || !valid_vma(vma, is_register)) |
848 | goto unlock; | 844 | goto unlock; |
849 | 845 | ||
850 | vaddr = vma_address(vma, uprobe->offset); | ||
851 | if (vma->vm_file->f_mapping->host != uprobe->inode || | 846 | if (vma->vm_file->f_mapping->host != uprobe->inode || |
852 | vaddr != info->vaddr) | 847 | vma_address(vma, uprobe->offset) != info->vaddr) |
853 | goto unlock; | 848 | goto unlock; |
854 | 849 | ||
855 | if (is_register) { | 850 | if (is_register) { |
@@ -1055,10 +1050,8 @@ int uprobe_mmap(struct vm_area_struct *vma) | |||
1055 | count = 0; | 1050 | count = 0; |
1056 | 1051 | ||
1057 | list_for_each_entry(uprobe, &tmp_list, pending_list) { | 1052 | list_for_each_entry(uprobe, &tmp_list, pending_list) { |
1058 | loff_t vaddr; | ||
1059 | |||
1060 | if (!ret) { | 1053 | if (!ret) { |
1061 | vaddr = vma_address(vma, uprobe->offset); | 1054 | loff_t vaddr = vma_address(vma, uprobe->offset); |
1062 | 1055 | ||
1063 | if (vaddr < vma->vm_start || vaddr >= vma->vm_end) { | 1056 | if (vaddr < vma->vm_start || vaddr >= vma->vm_end) { |
1064 | put_uprobe(uprobe); | 1057 | put_uprobe(uprobe); |
@@ -1122,9 +1115,8 @@ void uprobe_munmap(struct vm_area_struct *vma, unsigned long start, unsigned lon | |||
1122 | build_probe_list(inode, &tmp_list); | 1115 | build_probe_list(inode, &tmp_list); |
1123 | 1116 | ||
1124 | list_for_each_entry(uprobe, &tmp_list, pending_list) { | 1117 | list_for_each_entry(uprobe, &tmp_list, pending_list) { |
1125 | loff_t vaddr; | 1118 | loff_t vaddr = vma_address(vma, uprobe->offset); |
1126 | 1119 | ||
1127 | vaddr = vma_address(vma, uprobe->offset); | ||
1128 | if (vaddr >= start && vaddr < end) { | 1120 | if (vaddr >= start && vaddr < end) { |
1129 | /* | 1121 | /* |
1130 | * An unregister could have removed the probe before | 1122 | * An unregister could have removed the probe before |