Re: [PATCH v41 10/24] mm: Add 'mprotect' hook to struct vm_operations_struct
From: Matthew Wilcox
Date: Sun Nov 15 2020 - 12:33:48 EST
On Fri, Nov 13, 2020 at 12:01:21AM +0200, Jarkko Sakkinen wrote:
> +++ b/include/linux/mm.h
> @@ -559,6 +559,13 @@ 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);
> + /*
> + * Called by mprotect() to make driver-specific permission
> + * checks before mprotect() is finalised. The VMA must not
> + * be modified. Returns 0 if eprotect() can proceed.
> + */
This is the wrong place for this documentation, and it's absurdly
specific to your implementation. It should be in
Documentation/filesystems/locking.rst.
> + int (*mprotect)(struct vm_area_struct *vma, unsigned long start,
> + unsigned long end, unsigned long newflags);
> +
> + if (vma->vm_ops && vma->vm_ops->mprotect)
> + error = vma->vm_ops->mprotect(vma, nstart, tmp, newflags);
> + if (error)
> + goto out;
> +
> error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
> if (error)
> goto out;
> +
> nstart = tmp;
Spurious newline added.