Re: [PATCH v2] mm: userfaultfd: avoid passing an invalid range to vma_merge()

From: Peter Xu
Date: Tue May 16 2023 - 18:52:42 EST


On Tue, May 16, 2023 at 06:38:30PM -0400, Liam R. Howlett wrote:
> > It seems to me what you're trying to explain is we shouldn't handle any
> > split in vma_merge() so we should move cases 4 & 5 out of vma_merge(). If
> > we split first then merge, cases 4 & 5 will become case 2 & 3 after split.
>
> We don't split in case 4 or 5 - we adjust the existing VMA limits. We
> don't actually handle any splits in vma_merge(). I think splitting
> first would change 4 & 5 to 7 & 8? 2 & 3 would require a split and
> munmap, right?

Right, I referenced to the wrong numbers.. 2 & 3 are when CUR (CCCC) is
empty and newly mapped in, if split happened it means CUR (CCCC) exists
which is 7 & 8 correspondingly.

>
> > My question would be: if it worked perfect in the past few years and it
> > looks all good enough, why bother..
>
> I suspect, but it's not clear (like all of this), that the other
> arguments to vma_merge() is ruling out this potential hazard I thought
> existed.

Some more elaborations on this one would be appreciated.

Thanks,

--
Peter Xu