mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-15 13:15:57 +00:00
uprobes: Copy_insn() shouldn't depend on mm/vma/vaddr
1. copy_insn() doesn't need "addr", it can use uprobe->offset. Remove this argument. 2. Change copy_insn/__copy_insn to accept "struct file*" instead of vma. copy_insn() is called only once and mm/vma/vaddr are random, it shouldn't depend on them. 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/20120615154342.GA9598@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
parent
c5784de2b3
commit
d436615e60
@ -591,10 +591,9 @@ static bool consumer_del(struct uprobe *uprobe, struct uprobe_consumer *uc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
__copy_insn(struct address_space *mapping, struct vm_area_struct *vma, char *insn,
|
__copy_insn(struct address_space *mapping, struct file *filp, char *insn,
|
||||||
unsigned long nbytes, unsigned long offset)
|
unsigned long nbytes, unsigned long offset)
|
||||||
{
|
{
|
||||||
struct file *filp = vma->vm_file;
|
|
||||||
struct page *page;
|
struct page *page;
|
||||||
void *vaddr;
|
void *vaddr;
|
||||||
unsigned long off1;
|
unsigned long off1;
|
||||||
@ -625,15 +624,13 @@ __copy_insn(struct address_space *mapping, struct vm_area_struct *vma, char *ins
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int copy_insn(struct uprobe *uprobe, struct file *filp)
|
||||||
copy_insn(struct uprobe *uprobe, struct vm_area_struct *vma, unsigned long addr)
|
|
||||||
{
|
{
|
||||||
struct address_space *mapping;
|
struct address_space *mapping;
|
||||||
unsigned long nbytes;
|
unsigned long nbytes;
|
||||||
int bytes;
|
int bytes;
|
||||||
|
|
||||||
addr &= ~PAGE_MASK;
|
nbytes = PAGE_SIZE - (uprobe->offset & ~PAGE_MASK);
|
||||||
nbytes = PAGE_SIZE - addr;
|
|
||||||
mapping = uprobe->inode->i_mapping;
|
mapping = uprobe->inode->i_mapping;
|
||||||
|
|
||||||
/* Instruction at end of binary; copy only available bytes */
|
/* Instruction at end of binary; copy only available bytes */
|
||||||
@ -644,13 +641,13 @@ copy_insn(struct uprobe *uprobe, struct vm_area_struct *vma, unsigned long addr)
|
|||||||
|
|
||||||
/* Instruction at the page-boundary; copy bytes in second page */
|
/* Instruction at the page-boundary; copy bytes in second page */
|
||||||
if (nbytes < bytes) {
|
if (nbytes < bytes) {
|
||||||
if (__copy_insn(mapping, vma, uprobe->arch.insn + nbytes,
|
if (__copy_insn(mapping, filp, uprobe->arch.insn + nbytes,
|
||||||
bytes - nbytes, uprobe->offset + nbytes))
|
bytes - nbytes, uprobe->offset + nbytes))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
bytes = nbytes;
|
bytes = nbytes;
|
||||||
}
|
}
|
||||||
return __copy_insn(mapping, vma, uprobe->arch.insn, bytes, uprobe->offset);
|
return __copy_insn(mapping, filp, uprobe->arch.insn, bytes, uprobe->offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -696,7 +693,7 @@ install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm,
|
|||||||
addr = (unsigned long)vaddr;
|
addr = (unsigned long)vaddr;
|
||||||
|
|
||||||
if (!(uprobe->flags & UPROBE_COPY_INSN)) {
|
if (!(uprobe->flags & UPROBE_COPY_INSN)) {
|
||||||
ret = copy_insn(uprobe, vma, addr);
|
ret = copy_insn(uprobe, vma->vm_file);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user