Re: [PATCH 01/10] cramfs: Convert to use vmf_insert_mixed

From: Matthew Wilcox
Date: Tue Aug 28 2018 - 18:04:30 EST


On Tue, Aug 28, 2018 at 01:49:25PM -0400, Nicolas Pitre wrote:
> On Tue, 28 Aug 2018, Matthew Wilcox wrote:
> > - ret = vm_insert_mixed(vma, vma->vm_start + off, pfn);
> > + vmf = vmf_insert_mixed(vma, vma->vm_start + off, pfn);
> > + if (vmf & VM_FAULT_ERROR) {
> > + pages = i;
> > + break;
> > + }
>
> I'd suggest this to properly deal with errers instead:
>
> - ret = vm_insert_mixed(vma, vma->vm_start + off, pfn);
> + vmf = vmf_insert_mixed(vma, vma->vm_start + off, pfn);
> + if (vmf & VM_FAULT_ERROR)
> + ret = vm_fault_to_errno(vmf, 0);

By my reading of this function, the intent is actually to return 0
here and allow demand paging to work. Of course, I've spent all of
twenty minutes staring at this function, so I defer to the maintainer.
I think you'd need to be running a make-memory-allocations-fail fuzzer
to hit this, so it's likely never been tested.