#include <asm/uaccess.h>
#include <asm/pgtable.h>
-#include <asm/pgalloc.h>
#include <asm/cacheflush.h>
#include <asm/tlbflush.h>
struct mm_struct *mm = vma->vm_mm;
unsigned long oldflags = vma->vm_flags;
long nrpages = (end - start) >> PAGE_SHIFT;
- unsigned long charged = 0, old_end = vma->vm_end;
+ unsigned long charged = 0;
pgprot_t newprot;
pgoff_t pgoff;
int error;
* a MAP_NORESERVE private mapping to writable will now reserve.
*/
if (newflags & VM_WRITE) {
- if (!(oldflags & (VM_ACCOUNT|VM_WRITE|VM_SHARED))) {
+ if (!(oldflags & (VM_ACCOUNT|VM_WRITE|VM_SHARED|VM_HUGETLB))) {
charged = nrpages;
if (security_vm_enough_memory(charged))
return -ENOMEM;
*/
vma->vm_flags = newflags;
vma->vm_page_prot = newprot;
- if (oldflags & VM_EXEC)
- arch_remove_exec_range(current->mm, old_end);
- if (is_vm_hugetlb_page(vma))
- hugetlb_change_protection(vma, start, end, newprot);
- else
- change_protection(vma, start, end, newprot);
+ 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;
/* 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_% */