Re: [PATCH v3 1/3] kernfs: remove page_mkwrite() from vm_operations_struct
From: Matthew Wilcox
Date: Thu Jul 04 2024 - 13:02:51 EST
On Thu, Jul 04, 2024 at 10:37:22AM -0600, Martin Oliveira wrote:
> @@ -482,6 +459,8 @@ static int kernfs_fop_mmap(struct file *file, struct vm_area_struct *vma)
> if (vma->vm_ops && vma->vm_ops->close)
> goto out_put;
>
> + WARN_ON(vma->vm_ops && vma->vm_ops->page_mkwrite);
> +
> rc = 0;
> if (!of->mmapped) {
> of->mmapped = true;
Seems to me we should actually _handle_ that, not do something wrong.
eg:
if (vma->vm_ops) {
if (vma->vm_ops->close)
goto out_put;
if (WARN_ON(vma->vm_ops->page_mkwrite))
goto out_put;
}
or maybe this doesn't need to be a WARN at all? After all, there
isn't one for having a ->close method, so why is page_mkwrite special?