Re: [PATCH] mm/vmalloc: Sanitize __get_vm_area() arguments

From: Uladzislau Rezki
Date: Sun Apr 05 2020 - 15:21:46 EST


On Sun, Apr 05, 2020 at 07:23:15PM +0200, Uladzislau Rezki wrote:
> On Sat, Apr 04, 2020 at 11:25:45PM -0600, William Kucharski wrote:
> >
> >
> > > On Apr 4, 2020, at 12:52 PM, Uladzislau Rezki <urezki@xxxxxxxxx> wrote:
> > >
> > >>
> > >> ïIs there any need to similarly sanitize âsizeâ to assure start + size doesnât go past âend?â
> > >>
> > > Why is that double check needed if all such tests are done deeper on stack?
> >
> > If such tests ARE performed, then it doesn't matter to me whether it is checked before or after,
> > it just seems that nothing checks whether start + size makes some sort of sense with respect
> > to end.
> >
> > I admit I didn't walk through all the routines to see if such a check would be superfluous.
> >
> Yes, we check it:
>
> <snip>
> static __always_inline bool
> is_within_this_va(struct vmap_area *va, unsigned long size,
> unsigned long align, unsigned long vstart)
> {
> ...
> return (nva_start_addr + size <= va->va_end);
> }
> <snip>
>
Sorry, was thinking about one place showed different one. Here we go:

<snip>
/* Check the "vend" restriction. */
if (nva_start_addr + size > vend)
return vend;
<snip>

--
Vlad Rezki