Re: [PATCH v2 3/7] mm/gup: remove vmas parameter from get_user_pages_remote()

From: Lorenzo Stoakes
Date: Sat Apr 15 2023 - 06:14:20 EST


On Sat, Apr 15, 2023 at 06:52:41PM +0900, Tetsuo Handa wrote:
> On 2023/04/15 18:08, Lorenzo Stoakes wrote:
> > @@ -475,10 +474,14 @@ int uprobe_write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm,
> > gup_flags |= FOLL_SPLIT_PMD;
> > /* Read the page with vaddr into memory */
> > ret = get_user_pages_remote(mm, vaddr, 1, gup_flags,
> > - &old_page, &vma, NULL);
> > + &old_page, NULL);
> > if (ret <= 0)
> > return ret;
> >
> > + vma = vma_lookup(mm, vaddr);
> > + if (!vma)
> > + goto put_old;
> > +
> > ret = verify_opcode(old_page, vaddr, &opcode);
> > if (ret <= 0)
> > goto put_old;
>
> This conversion looks wrong.
> This causes returning a positive number when vma_lookup() returned NULL.
>
> * Return 0 (success) or a negative errno.
>

In reality it shouldn't be possible for vma to return NULL, I'm adding the
checks to be extra careful.

In any case you're right, attaching a -fix patch to avoid spam:-

----8<----