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]
Date:   Tue, 29 Sep 2020 09:14:24 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     Souptick Joarder <jrdr.linux@...il.com>
Cc:     "open list:ANDROID DRIVERS" <devel@...verdev.osuosl.org>,
        Michel Lespinasse <walken@...gle.com>,
        Greg KH <gregkh@...uxfoundation.org>, gustavoars@...nel.org,
        daniel.m.jordan@...cle.com, sakari.ailus@...ux.intel.com,
        John Hubbard <jhubbard@...dia.com>,
        Andrew Morton <akpm@...ux-foundation.org>, mchehab@...nel.org,
        linux-kernel@...r.kernel.org, linux-media@...r.kernel.org
Subject: Re: [PATCH] media: atomisp: Fixed error handling path

On Tue, Sep 29, 2020 at 07:34:39AM +0530, Souptick Joarder wrote:
> Hi Dan,
> 
> 
> On Mon, Sep 28, 2020 at 2:08 PM Dan Carpenter <dan.carpenter@...cle.com> wrote:
> >
> > On Sun, Sep 27, 2020 at 08:38:04PM +0530, Souptick Joarder wrote:
> > > Inside alloc_user_pages() based on flag value either pin_user_pages()
> > > or get_user_pages_fast() will be called. However, these API might fail.
> > >
> > > But free_user_pages() called in error handling path doesn't bother
> > > about return value and will try to unpin bo->pgnr pages, which is
> > > incorrect.
> > >
> > > Fix this by passing the page_nr to free_user_pages(). If page_nr > 0
> > > pages will be unpinned based on bo->mem_type. This will also take care
> > > of non error handling path.
> > >
> > > Fixes: 14a638ab96c5 ("media: atomisp: use pin_user_pages() for memory
> > > allocation")
> > > Signed-off-by: Souptick Joarder <jrdr.linux@...il.com>
> > > Cc: John Hubbard <jhubbard@...dia.com>
> > > Cc: Ira Weiny <ira.weiny@...el.com>
> > > Cc: Dan Carpenter <dan.carpenter@...cle.com>
> > > ---
> > >  drivers/staging/media/atomisp/pci/hmm/hmm_bo.c | 13 ++++++++-----
> > >  1 file changed, 8 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c b/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c
> > > index f13af23..0168f98 100644
> > > --- a/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c
> > > +++ b/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c
> > > @@ -857,16 +857,17 @@ static void free_private_pages(struct hmm_buffer_object *bo,
> > >       kfree(bo->page_obj);
> > >  }
> > >
> > > -static void free_user_pages(struct hmm_buffer_object *bo)
> > > +static void free_user_pages(struct hmm_buffer_object *bo,
> > > +                         unsigned int page_nr)
> > >  {
> > >       int i;
> > >
> > >       hmm_mem_stat.usr_size -= bo->pgnr;
> >                               ^^^^^^^^^^^
> > This is still a problem.  It needs to be hmm_mem_stat.usr_size -= page_nr.
> 
> In failure path, it is hmm_mem_stat.usr_size += bo->pgnr.
> I think, hmm_mem_stat.usr_size -= bo->pgnr is correct as per existing code.
> Do you think that needs to be changed ?
> 

Yeah.  Crud.  I'm sorry.  You had it right.

Reviewed-by: Dan Carpenter <dan.carpenter@...cle.com>

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ