diff options
-rw-r--r-- | fs/proc/task_mmu.c | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 88717c0f941b..17403629e330 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
@@ -496,7 +496,7 @@ const struct file_operations proc_clear_refs_operations = { | |||
496 | }; | 496 | }; |
497 | 497 | ||
498 | struct pagemapread { | 498 | struct pagemapread { |
499 | char __user *out, *end; | 499 | u64 __user *out, *end; |
500 | }; | 500 | }; |
501 | 501 | ||
502 | #define PM_ENTRY_BYTES sizeof(u64) | 502 | #define PM_ENTRY_BYTES sizeof(u64) |
@@ -519,21 +519,11 @@ struct pagemapread { | |||
519 | static int add_to_pagemap(unsigned long addr, u64 pfn, | 519 | static int add_to_pagemap(unsigned long addr, u64 pfn, |
520 | struct pagemapread *pm) | 520 | struct pagemapread *pm) |
521 | { | 521 | { |
522 | /* | ||
523 | * Make sure there's room in the buffer for an | ||
524 | * entire entry. Otherwise, only copy part of | ||
525 | * the pfn. | ||
526 | */ | ||
527 | if (pm->out + PM_ENTRY_BYTES >= pm->end) { | ||
528 | if (copy_to_user(pm->out, &pfn, pm->end - pm->out)) | ||
529 | return -EFAULT; | ||
530 | pm->out = pm->end; | ||
531 | return PM_END_OF_BUFFER; | ||
532 | } | ||
533 | |||
534 | if (put_user(pfn, pm->out)) | 522 | if (put_user(pfn, pm->out)) |
535 | return -EFAULT; | 523 | return -EFAULT; |
536 | pm->out += PM_ENTRY_BYTES; | 524 | pm->out++; |
525 | if (pm->out >= pm->end) | ||
526 | return PM_END_OF_BUFFER; | ||
537 | return 0; | 527 | return 0; |
538 | } | 528 | } |
539 | 529 | ||
@@ -634,7 +624,7 @@ static ssize_t pagemap_read(struct file *file, char __user *buf, | |||
634 | 624 | ||
635 | ret = -EINVAL; | 625 | ret = -EINVAL; |
636 | /* file position must be aligned */ | 626 | /* file position must be aligned */ |
637 | if (*ppos % PM_ENTRY_BYTES) | 627 | if ((*ppos % PM_ENTRY_BYTES) || (count % PM_ENTRY_BYTES)) |
638 | goto out_task; | 628 | goto out_task; |
639 | 629 | ||
640 | ret = 0; | 630 | ret = 0; |
@@ -664,8 +654,8 @@ static ssize_t pagemap_read(struct file *file, char __user *buf, | |||
664 | goto out_pages; | 654 | goto out_pages; |
665 | } | 655 | } |
666 | 656 | ||
667 | pm.out = buf; | 657 | pm.out = (u64 *)buf; |
668 | pm.end = buf + count; | 658 | pm.end = (u64 *)(buf + count); |
669 | 659 | ||
670 | if (!ptrace_may_attach(task)) { | 660 | if (!ptrace_may_attach(task)) { |
671 | ret = -EIO; | 661 | ret = -EIO; |
@@ -690,9 +680,9 @@ static ssize_t pagemap_read(struct file *file, char __user *buf, | |||
690 | if (ret == PM_END_OF_BUFFER) | 680 | if (ret == PM_END_OF_BUFFER) |
691 | ret = 0; | 681 | ret = 0; |
692 | /* don't need mmap_sem for these, but this looks cleaner */ | 682 | /* don't need mmap_sem for these, but this looks cleaner */ |
693 | *ppos += pm.out - buf; | 683 | *ppos += (char *)pm.out - buf; |
694 | if (!ret) | 684 | if (!ret) |
695 | ret = pm.out - buf; | 685 | ret = (char *)pm.out - buf; |
696 | } | 686 | } |
697 | 687 | ||
698 | out_pages: | 688 | out_pages: |