@@ -542,6 +542,8 @@ struct vm_operations_struct {
void (*close)(struct vm_area_struct * area);
int (*split)(struct vm_area_struct * area, unsigned long addr);
int (*mremap)(struct vm_area_struct * area);
+ int (*mprotect)(struct vm_area_struct *vma, unsigned long start,
+ unsigned long end, unsigned long prot);
vm_fault_t (*fault)(struct vm_fault *vmf);
vm_fault_t (*huge_fault)(struct vm_fault *vmf,
enum page_entry_size pe_size);
@@ -603,13 +603,20 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
goto out;
}
+ tmp = vma->vm_end;
+ if (tmp > end)
+ tmp = end;
+
error = security_file_mprotect(vma, reqprot, prot);
if (error)
goto out;
- tmp = vma->vm_end;
- if (tmp > end)
- tmp = end;
+ if (vma->vm_ops && vma->vm_ops->mprotect) {
+ error = vma->vm_ops->mprotect(vma, nstart, tmp, prot);
+ if (error)
+ goto out;
+ }
+
error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
if (error)
goto out;