aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2013-11-11 03:44:16 -0500
committerIngo Molnar <mingo@kernel.org>2013-11-11 03:44:16 -0500
commitcaea6cf52139116e43e615d87fcbf9823e197fdf (patch)
treec2a316644581019db086d62181eddef1dd04e91c
parent4d9218daae2b00379b2bb81eaf4fe5143f372db1 (diff)
parent2ded0980a6e4ae96bdd84bda66c7240967d86f3c (diff)
Merge branch 'uprobes/core' of git://git.kernel.org/pub/scm/linux/kernel/git/oleg/misc into perf/core
Pull uprobes fixes from Oleg Nesterov. Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--kernel/events/uprobes.c45
1 files changed, 22 insertions, 23 deletions
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 0ac346ae5edb..24b7d6ca871b 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -504,9 +504,8 @@ static bool consumer_del(struct uprobe *uprobe, struct uprobe_consumer *uc)
504 return ret; 504 return ret;
505} 505}
506 506
507static int 507static int __copy_insn(struct address_space *mapping, struct file *filp,
508__copy_insn(struct address_space *mapping, struct file *filp, char *insn, 508 void *insn, int nbytes, loff_t offset)
509 unsigned long nbytes, loff_t offset)
510{ 509{
511 struct page *page; 510 struct page *page;
512 511
@@ -528,28 +527,28 @@ __copy_insn(struct address_space *mapping, struct file *filp, char *insn,
528 527
529static int copy_insn(struct uprobe *uprobe, struct file *filp) 528static int copy_insn(struct uprobe *uprobe, struct file *filp)
530{ 529{
531 struct address_space *mapping; 530 struct address_space *mapping = uprobe->inode->i_mapping;
532 unsigned long nbytes; 531 loff_t offs = uprobe->offset;
533 int bytes; 532 void *insn = uprobe->arch.insn;
534 533 int size = MAX_UINSN_BYTES;
535 nbytes = PAGE_SIZE - (uprobe->offset & ~PAGE_MASK); 534 int len, err = -EIO;
536 mapping = uprobe->inode->i_mapping;
537 535
538 /* Instruction at end of binary; copy only available bytes */ 536 /* Copy only available bytes, -EIO if nothing was read */
539 if (uprobe->offset + MAX_UINSN_BYTES > uprobe->inode->i_size) 537 do {
540 bytes = uprobe->inode->i_size - uprobe->offset; 538 if (offs >= i_size_read(uprobe->inode))
541 else 539 break;
542 bytes = MAX_UINSN_BYTES;
543 540
544 /* Instruction at the page-boundary; copy bytes in second page */ 541 len = min_t(int, size, PAGE_SIZE - (offs & ~PAGE_MASK));
545 if (nbytes < bytes) { 542 err = __copy_insn(mapping, filp, insn, len, offs);
546 int err = __copy_insn(mapping, filp, uprobe->arch.insn + nbytes,
547 bytes - nbytes, uprobe->offset + nbytes);
548 if (err) 543 if (err)
549 return err; 544 break;
550 bytes = nbytes; 545
551 } 546 insn += len;
552 return __copy_insn(mapping, filp, uprobe->arch.insn, bytes, uprobe->offset); 547 offs += len;
548 size -= len;
549 } while (size);
550
551 return err;
553} 552}
554 553
555static int prepare_uprobe(struct uprobe *uprobe, struct file *file, 554static int prepare_uprobe(struct uprobe *uprobe, struct file *file,
@@ -1447,7 +1446,7 @@ void uprobe_copy_process(struct task_struct *t, unsigned long flags)
1447 if (!work) 1446 if (!work)
1448 return uprobe_warn(t, "dup xol area"); 1447 return uprobe_warn(t, "dup xol area");
1449 1448
1450 utask->vaddr = area->vaddr; 1449 t->utask->vaddr = area->vaddr;
1451 init_task_work(work, dup_xol_work); 1450 init_task_work(work, dup_xol_work);
1452 task_work_add(t, work, true); 1451 task_work_add(t, work, true);
1453} 1452}