Re: [PATCH v4 6/6] mm: handle userfaults under VMA lock

From: Peter Xu
Date: Wed Jun 28 2023 - 12:49:04 EST


On Wed, Jun 28, 2023 at 09:22:24AM -0700, Suren Baghdasaryan wrote:
> Ack. I was not sure if the ctx->mm would always be the same as vmf->mm.

Feel free to look at the entrance of handle_userfault(), where there's:

struct vm_area_struct *vma = vmf->vma;
struct mm_struct *mm = vma->vm_mm;
struct userfaultfd_ctx *ctx;
...
ctx = vma->vm_userfaultfd_ctx.ctx;
...
BUG_ON(ctx->mm != mm);
...

So I think we should be safe. Thanks,

--
Peter Xu