lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAGsJ_4wwrnO_Fri6acjoTDTr+G0rmCZsPie-ahVzM9runHQpTw@mail.gmail.com>
Date: Tue, 23 Apr 2024 08:52:13 +0800
From: Barry Song <21cnbao@...il.com>
To: Hailong Liu <hailong.liu@...o.com>
Cc: akpm@...ux-foundation.org, urezki@...il.com, hch@...radead.org, 
	lstoakes@...il.com, linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH v2] mm/vmalloc: fix return value of vb_alloc if size
 is 0.

On Mon, Apr 22, 2024 at 6:39 PM Hailong Liu <hailong.liu@...o.com> wrote:
>
> On Mon, 22. Apr 11:46, Barry Song wrote:
> > On Fri, Apr 19, 2024 at 6:17 PM <hailong.liu@...o.com> wrote:
> > >
> > > From: "Hailong.Liu" <hailong.liu@...o.com>
> > >
> > > vm_map_ram check return value of vb_alloc by IS_ERR. if
> > > vm_map_ram(page, 0, 0) , vb_alloc(0, GFP_KERNEL) would return NULL
> > > which cause kernel panic by vmap_pages_range_noflush。fix this by
> > > return ERR_PTR(-EINVAL) if size is 0.
> > >
> > > Signed-off-by: Hailong.Liu <hailong.liu@...o.com>
> > > ---
> > > Changes since v1 [1]:
> > > - Return ERR_PTR(-EINVAL) or not check IS_ERR_OR_NULL
> > >
> > > BTW,  Barry suggests me that if count is 0, return directly, in my
> > > opinion, change return value is more resonable.
> > >
> > > [1] https://lore.kernel.org/all/84d7cd03-1cf8-401a-8edf-2524db0bd6d5@oppo.com/
> > >
> > >  mm/vmalloc.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> > > index a3fedb3ee0db..c430a999805b 100644
> > > --- a/mm/vmalloc.c
> > > +++ b/mm/vmalloc.c
> > > @@ -2173,7 +2173,7 @@ static void *vb_alloc(unsigned long size, gfp_t gfp_mask)
> > >                  * get_order(0) returns funny result. Just warn and terminate
> > >                  * early.
> > >                  */
> > > -               return NULL;
> > > +               return ERR_PTR(-EINVAL);
> >
> > might be ZERO_SIZE_PTR.
>
> Hi Barry,
> Hi Barry, I use ERR_PTR(-EINVAL) to keep consistency with the return
> value of the function alloc_vmap_area.
>
>         if (unlikely(!size || offset_in_page(size) || !is_power_of_2(align)))
>                 return ERR_PTR(-EINVAL);
>
> IMO, ZERO_SIZE_PTR is used by slab and can not be catched by IS_ERR().

Ok. it seems not worth to change two places.

Reviewed-by: Barry Song <baohua@...nel.org>

>
> --
> Best Regards,
> Hailong.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ