Skip to content

Commit

Permalink
uprobes: __copy_insn() needs "loff_t offset"
Browse files Browse the repository at this point in the history
1. __copy_insn() needs "loff_t offset", not "unsigned long",
   to read the file.

2. use pgoff_t for "idx" and remove the unnecessary typecast.

3. fix the typo, "&=" is not what we want

4. can't resist, rename off1 to off.

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/20120615154359.GA9625@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Oleg Nesterov authored and Ingo Molnar committed Jun 16, 2012
1 parent 816c03f commit 593609a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions kernel/events/uprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,21 +581,21 @@ static bool consumer_del(struct uprobe *uprobe, struct uprobe_consumer *uc)

static int
__copy_insn(struct address_space *mapping, struct file *filp, char *insn,
unsigned long nbytes, unsigned long offset)
unsigned long nbytes, loff_t offset)
{
struct page *page;
void *vaddr;
unsigned long off1;
unsigned long idx;
unsigned long off;
pgoff_t idx;

if (!filp)
return -EINVAL;

if (!mapping->a_ops->readpage)
return -EIO;

idx = (unsigned long)(offset >> PAGE_CACHE_SHIFT);
off1 = offset &= ~PAGE_MASK;
idx = offset >> PAGE_CACHE_SHIFT;
off = offset & ~PAGE_MASK;

/*
* Ensure that the page that has the original instruction is
Expand All @@ -606,7 +606,7 @@ __copy_insn(struct address_space *mapping, struct file *filp, char *insn,
return PTR_ERR(page);

vaddr = kmap_atomic(page);
memcpy(insn, vaddr + off1, nbytes);
memcpy(insn, vaddr + off, nbytes);
kunmap_atomic(vaddr);
page_cache_release(page);

Expand Down

0 comments on commit 593609a

Please sign in to comment.