diff options
Diffstat (limited to 'mm')
-rw-r--r-- | mm/mempolicy.c | 8 | ||||
-rw-r--r-- | mm/vmscan.c | 18 |
2 files changed, 16 insertions, 10 deletions
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 954981b14303..2a8206009422 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c | |||
@@ -748,7 +748,7 @@ long do_mbind(unsigned long start, unsigned long len, | |||
748 | MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) | 748 | MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) |
749 | || mode > MPOL_MAX) | 749 | || mode > MPOL_MAX) |
750 | return -EINVAL; | 750 | return -EINVAL; |
751 | if ((flags & MPOL_MF_MOVE_ALL) && !capable(CAP_SYS_RESOURCE)) | 751 | if ((flags & MPOL_MF_MOVE_ALL) && !capable(CAP_SYS_NICE)) |
752 | return -EPERM; | 752 | return -EPERM; |
753 | 753 | ||
754 | if (start & ~PAGE_MASK) | 754 | if (start & ~PAGE_MASK) |
@@ -942,20 +942,20 @@ asmlinkage long sys_migrate_pages(pid_t pid, unsigned long maxnode, | |||
942 | */ | 942 | */ |
943 | if ((current->euid != task->suid) && (current->euid != task->uid) && | 943 | if ((current->euid != task->suid) && (current->euid != task->uid) && |
944 | (current->uid != task->suid) && (current->uid != task->uid) && | 944 | (current->uid != task->suid) && (current->uid != task->uid) && |
945 | !capable(CAP_SYS_ADMIN)) { | 945 | !capable(CAP_SYS_NICE)) { |
946 | err = -EPERM; | 946 | err = -EPERM; |
947 | goto out; | 947 | goto out; |
948 | } | 948 | } |
949 | 949 | ||
950 | task_nodes = cpuset_mems_allowed(task); | 950 | task_nodes = cpuset_mems_allowed(task); |
951 | /* Is the user allowed to access the target nodes? */ | 951 | /* Is the user allowed to access the target nodes? */ |
952 | if (!nodes_subset(new, task_nodes) && !capable(CAP_SYS_ADMIN)) { | 952 | if (!nodes_subset(new, task_nodes) && !capable(CAP_SYS_NICE)) { |
953 | err = -EPERM; | 953 | err = -EPERM; |
954 | goto out; | 954 | goto out; |
955 | } | 955 | } |
956 | 956 | ||
957 | err = do_migrate_pages(mm, &old, &new, | 957 | err = do_migrate_pages(mm, &old, &new, |
958 | capable(CAP_SYS_ADMIN) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE); | 958 | capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE); |
959 | out: | 959 | out: |
960 | mmput(mm); | 960 | mmput(mm); |
961 | return err; | 961 | return err; |
diff --git a/mm/vmscan.c b/mm/vmscan.c index 7ccf763bb30b..4fe7e3aa02e2 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -700,7 +700,7 @@ int migrate_page_remove_references(struct page *newpage, | |||
700 | * the page. | 700 | * the page. |
701 | */ | 701 | */ |
702 | if (!mapping || page_mapcount(page) + nr_refs != page_count(page)) | 702 | if (!mapping || page_mapcount(page) + nr_refs != page_count(page)) |
703 | return 1; | 703 | return -EAGAIN; |
704 | 704 | ||
705 | /* | 705 | /* |
706 | * Establish swap ptes for anonymous pages or destroy pte | 706 | * Establish swap ptes for anonymous pages or destroy pte |
@@ -721,13 +721,15 @@ int migrate_page_remove_references(struct page *newpage, | |||
721 | * If the page was not migrated then the PageSwapCache bit | 721 | * If the page was not migrated then the PageSwapCache bit |
722 | * is still set and the operation may continue. | 722 | * is still set and the operation may continue. |
723 | */ | 723 | */ |
724 | try_to_unmap(page, 1); | 724 | if (try_to_unmap(page, 1) == SWAP_FAIL) |
725 | /* A vma has VM_LOCKED set -> Permanent failure */ | ||
726 | return -EPERM; | ||
725 | 727 | ||
726 | /* | 728 | /* |
727 | * Give up if we were unable to remove all mappings. | 729 | * Give up if we were unable to remove all mappings. |
728 | */ | 730 | */ |
729 | if (page_mapcount(page)) | 731 | if (page_mapcount(page)) |
730 | return 1; | 732 | return -EAGAIN; |
731 | 733 | ||
732 | write_lock_irq(&mapping->tree_lock); | 734 | write_lock_irq(&mapping->tree_lock); |
733 | 735 | ||
@@ -738,7 +740,7 @@ int migrate_page_remove_references(struct page *newpage, | |||
738 | if (!page_mapping(page) || page_count(page) != nr_refs || | 740 | if (!page_mapping(page) || page_count(page) != nr_refs || |
739 | *radix_pointer != page) { | 741 | *radix_pointer != page) { |
740 | write_unlock_irq(&mapping->tree_lock); | 742 | write_unlock_irq(&mapping->tree_lock); |
741 | return 1; | 743 | return -EAGAIN; |
742 | } | 744 | } |
743 | 745 | ||
744 | /* | 746 | /* |
@@ -813,10 +815,14 @@ EXPORT_SYMBOL(migrate_page_copy); | |||
813 | */ | 815 | */ |
814 | int migrate_page(struct page *newpage, struct page *page) | 816 | int migrate_page(struct page *newpage, struct page *page) |
815 | { | 817 | { |
818 | int rc; | ||
819 | |||
816 | BUG_ON(PageWriteback(page)); /* Writeback must be complete */ | 820 | BUG_ON(PageWriteback(page)); /* Writeback must be complete */ |
817 | 821 | ||
818 | if (migrate_page_remove_references(newpage, page, 2)) | 822 | rc = migrate_page_remove_references(newpage, page, 2); |
819 | return -EAGAIN; | 823 | |
824 | if (rc) | ||
825 | return rc; | ||
820 | 826 | ||
821 | migrate_page_copy(newpage, page); | 827 | migrate_page_copy(newpage, page); |
822 | 828 | ||