Pull bugzilla-5452 into release branch
[pandora-kernel.git] / mm / mprotect.c
index 17a2b52..4c14d42 100644 (file)
@@ -124,15 +124,7 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
         * a MAP_NORESERVE private mapping to writable will now reserve.
         */
        if (newflags & VM_WRITE) {
-               if (oldflags & VM_RESERVED) {
-                       BUG_ON(oldflags & VM_WRITE);
-                       printk(KERN_WARNING "program %s is using MAP_PRIVATE, "
-                               "PROT_WRITE mprotect of VM_RESERVED memory, "
-                               "which is deprecated. Please report this to "
-                               "linux-kernel@vger.kernel.org\n",current->comm);
-                       return -EACCES;
-               }
-               if (!(oldflags & (VM_ACCOUNT|VM_WRITE|VM_SHARED|VM_HUGETLB))) {
+               if (!(oldflags & (VM_ACCOUNT|VM_WRITE|VM_SHARED))) {
                        charged = nrpages;
                        if (security_vm_enough_memory(charged))
                                return -ENOMEM;
@@ -174,7 +166,10 @@ success:
         */
        vma->vm_flags = newflags;
        vma->vm_page_prot = newprot;
-       change_protection(vma, start, end, newprot);
+       if (is_vm_hugetlb_page(vma))
+               hugetlb_change_protection(vma, start, end, newprot);
+       else
+               change_protection(vma, start, end, newprot);
        vm_stat_account(mm, oldflags, vma->vm_file, -nrpages);
        vm_stat_account(mm, newflags, vma->vm_file, nrpages);
        return 0;
@@ -248,11 +243,6 @@ sys_mprotect(unsigned long start, size_t len, unsigned long prot)
 
                /* Here we know that  vma->vm_start <= nstart < vma->vm_end. */
 
-               if (is_vm_hugetlb_page(vma)) {
-                       error = -EACCES;
-                       goto out;
-               }
-
                newflags = vm_flags | (vma->vm_flags & ~(VM_READ | VM_WRITE | VM_EXEC));
 
                /* newflags >> 4 shift VM_MAY% in place of VM_% */