Re: [PATCH v34 10/24] mm: Add vm_ops->mprotect()

From: Matthew Wilcox
Date: Mon Jul 06 2020 - 23:14:35 EST


On Tue, Jul 07, 2020 at 06:01:50AM +0300, Jarkko Sakkinen wrote:
> +++ b/mm/mprotect.c
> @@ -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;

You don't need to move this any more, right?

> + 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;
> --
> 2.25.1
>