Commit 816c03fb authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Ingo Molnar

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: default avatarOleg Nesterov <oleg@redhat.com>
Signed-off-by: default avatarAnton Arapov <anton@redhat.com>
Acked-by: default avatarSrikar Dronamraju <srikar@linux.vnet.ibm.com>
Acked-by: default avatarAnanth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20120615154355.GA9622@redhat.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 449d0d7c
...@@ -664,9 +664,8 @@ static int copy_insn(struct uprobe *uprobe, struct file *filp) ...@@ -664,9 +664,8 @@ static int copy_insn(struct uprobe *uprobe, struct file *filp)
*/ */
static int static int
install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm,
struct vm_area_struct *vma, loff_t vaddr) struct vm_area_struct *vma, unsigned long vaddr)
{ {
unsigned long addr;
int ret; int ret;
/* /*
...@@ -679,8 +678,6 @@ install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, ...@@ -679,8 +678,6 @@ install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm,
if (!uprobe->consumers) if (!uprobe->consumers)
return -EEXIST; return -EEXIST;
addr = (unsigned long)vaddr;
if (!(uprobe->flags & UPROBE_COPY_INSN)) { if (!(uprobe->flags & UPROBE_COPY_INSN)) {
ret = copy_insn(uprobe, vma->vm_file); ret = copy_insn(uprobe, vma->vm_file);
if (ret) if (ret)
...@@ -689,7 +686,7 @@ install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, ...@@ -689,7 +686,7 @@ install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm,
if (is_swbp_insn((uprobe_opcode_t *)uprobe->arch.insn)) if (is_swbp_insn((uprobe_opcode_t *)uprobe->arch.insn))
return -ENOTSUPP; return -ENOTSUPP;
ret = arch_uprobe_analyze_insn(&uprobe->arch, mm, addr); ret = arch_uprobe_analyze_insn(&uprobe->arch, mm, vaddr);
if (ret) if (ret)
return ret; return ret;
...@@ -709,7 +706,7 @@ install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, ...@@ -709,7 +706,7 @@ install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm,
* Hence increment before and decrement on failure. * Hence increment before and decrement on failure.
*/ */
atomic_inc(&mm->uprobes_state.count); atomic_inc(&mm->uprobes_state.count);
ret = set_swbp(&uprobe->arch, mm, addr); ret = set_swbp(&uprobe->arch, mm, vaddr);
if (ret) if (ret)
atomic_dec(&mm->uprobes_state.count); atomic_dec(&mm->uprobes_state.count);
...@@ -717,9 +714,9 @@ install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, ...@@ -717,9 +714,9 @@ install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm,
} }
static void static void
remove_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, loff_t vaddr) remove_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, unsigned long vaddr)
{ {
if (!set_orig_insn(&uprobe->arch, mm, (unsigned long)vaddr, true)) if (!set_orig_insn(&uprobe->arch, mm, vaddr, true))
atomic_dec(&mm->uprobes_state.count); atomic_dec(&mm->uprobes_state.count);
} }
...@@ -743,7 +740,7 @@ static void delete_uprobe(struct uprobe *uprobe) ...@@ -743,7 +740,7 @@ static void delete_uprobe(struct uprobe *uprobe)
struct map_info { struct map_info {
struct map_info *next; struct map_info *next;
struct mm_struct *mm; struct mm_struct *mm;
loff_t vaddr; unsigned long vaddr;
}; };
static inline struct map_info *free_map_info(struct map_info *info) 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,7 +834,6 @@ static int register_for_each_vma(struct uprobe *uprobe, bool is_register)
while (info) { while (info) {
struct mm_struct *mm = info->mm; struct mm_struct *mm = info->mm;
struct vm_area_struct *vma; struct vm_area_struct *vma;
loff_t vaddr;
if (err) if (err)
goto free; goto free;
...@@ -847,9 +843,8 @@ static int register_for_each_vma(struct uprobe *uprobe, bool is_register) ...@@ -847,9 +843,8 @@ static int register_for_each_vma(struct uprobe *uprobe, bool is_register)
if (!vma || !valid_vma(vma, is_register)) if (!vma || !valid_vma(vma, is_register))
goto unlock; goto unlock;
vaddr = vma_address(vma, uprobe->offset);
if (vma->vm_file->f_mapping->host != uprobe->inode || if (vma->vm_file->f_mapping->host != uprobe->inode ||
vaddr != info->vaddr) vma_address(vma, uprobe->offset) != info->vaddr)
goto unlock; goto unlock;
if (is_register) { if (is_register) {
...@@ -1055,10 +1050,8 @@ int uprobe_mmap(struct vm_area_struct *vma) ...@@ -1055,10 +1050,8 @@ int uprobe_mmap(struct vm_area_struct *vma)
count = 0; count = 0;
list_for_each_entry(uprobe, &tmp_list, pending_list) { list_for_each_entry(uprobe, &tmp_list, pending_list) {
loff_t vaddr;
if (!ret) { if (!ret) {
vaddr = vma_address(vma, uprobe->offset); loff_t vaddr = vma_address(vma, uprobe->offset);
if (vaddr < vma->vm_start || vaddr >= vma->vm_end) { if (vaddr < vma->vm_start || vaddr >= vma->vm_end) {
put_uprobe(uprobe); put_uprobe(uprobe);
...@@ -1122,9 +1115,8 @@ void uprobe_munmap(struct vm_area_struct *vma, unsigned long start, unsigned lon ...@@ -1122,9 +1115,8 @@ void uprobe_munmap(struct vm_area_struct *vma, unsigned long start, unsigned lon
build_probe_list(inode, &tmp_list); build_probe_list(inode, &tmp_list);
list_for_each_entry(uprobe, &tmp_list, pending_list) { list_for_each_entry(uprobe, &tmp_list, pending_list) {
loff_t vaddr; loff_t vaddr = vma_address(vma, uprobe->offset);
vaddr = vma_address(vma, uprobe->offset);
if (vaddr >= start && vaddr < end) { if (vaddr >= start && vaddr < end) {
/* /*
* An unregister could have removed the probe before * An unregister could have removed the probe before
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment