On Fri, 2011-11-18 at 16:37 +0530, Srikar Dronamraju wrote: > +static int __copy_insn(struct address_space *mapping, > + struct vm_area_struct *vma, char *insn, > + unsigned long nbytes, unsigned long offset) > +{ > + struct file *filp = vma->vm_file; > + struct page *page; > + void *vaddr; > + unsigned long off1; > + unsigned long idx; > + > + if (!filp) > + return -EINVAL; > + > + idx = (unsigned long)(offset >> PAGE_CACHE_SHIFT); > + off1 = offset &= ~PAGE_MASK; > + > + /* > + * Ensure that the page that has the original instruction is > + * populated and in page-cache. > + */ > + page = read_mapping_page(mapping, idx, filp); > + if (IS_ERR(page)) > + return -ENOMEM; > + > + vaddr = kmap_atomic(page); > + memcpy(insn, vaddr + off1, nbytes); > + kunmap_atomic(vaddr); > + page_cache_release(page); > + return 0; > +} > + > +static int copy_insn(struct uprobe *uprobe, struct vm_area_struct *vma, > + unsigned long addr) > +{ > + struct address_space *mapping; > + int bytes; > + unsigned long nbytes; > + > + addr &= ~PAGE_MASK; > + nbytes = PAGE_SIZE - addr; > + mapping = uprobe->inode->i_mapping; > + > + /* Instruction at end of binary; copy only available bytes */ > + if (uprobe->offset + MAX_UINSN_BYTES > uprobe->inode->i_size) > + bytes = uprobe->inode->i_size - uprobe->offset; > + else > + bytes = MAX_UINSN_BYTES; > + > + /* Instruction at the page-boundary; copy bytes in second page */ > + if (nbytes < bytes) { > + if (__copy_insn(mapping, vma, uprobe->insn + nbytes, > + bytes - nbytes, uprobe->offset + nbytes)) > + return -ENOMEM; You just lost your possible -EINVAL return value. > + > + bytes = nbytes; > + } > + return __copy_insn(mapping, vma, uprobe->insn, bytes, uprobe->offset); > +} -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href