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] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 23 Oct 2019 11:16:01 +0200
From:   Daniel Vetter <daniel@...ll.ch>
To:     Navid Emamdoost <navid.emamdoost@...il.com>
Cc:     Daniel Vetter <daniel@...ll.ch>,
        Navid Emamdoost <emamd001@....edu>, Kangjie Lu <kjlu@....edu>,
        Stephen McCamant <smccaman@....edu>,
        Eric Anholt <eric@...olt.net>, David Airlie <airlied@...ux.ie>,
        dri-devel@...ts.freedesktop.org,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] drm/v3d: Fix memory leak in v3d_submit_cl_ioctl

On Tue, Oct 22, 2019 at 10:53:57PM -0500, Navid Emamdoost wrote:
> On Tue, Oct 22, 2019 at 4:36 AM Daniel Vetter <daniel@...ll.ch> wrote:
> >
> > On Mon, Oct 21, 2019 at 01:52:49PM -0500, Navid Emamdoost wrote:
> > > In the impelementation of v3d_submit_cl_ioctl() there are two memory
> > > leaks. One is when allocation for bin fails, and the other is when bin
> > > initialization fails. If kcalloc fails to allocate memory for bin then
> > > render->base should be put. Also, if v3d_job_init() fails to initialize
> > > bin->base then allocated memory for bin should be released.
> > >
> > > Fixes: a783a09ee76d ("drm/v3d: Refactor job management.")
> > > Signed-off-by: Navid Emamdoost <navid.emamdoost@...il.com>
> > > ---
> > >  drivers/gpu/drm/v3d/v3d_gem.c | 5 ++++-
> > >  1 file changed, 4 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/gpu/drm/v3d/v3d_gem.c b/drivers/gpu/drm/v3d/v3d_gem.c
> > > index 5d80507b539b..19c092d75266 100644
> > > --- a/drivers/gpu/drm/v3d/v3d_gem.c
> > > +++ b/drivers/gpu/drm/v3d/v3d_gem.c
> > > @@ -557,13 +557,16 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
> > >
> > >       if (args->bcl_start != args->bcl_end) {
> > >               bin = kcalloc(1, sizeof(*bin), GFP_KERNEL);
> > > -             if (!bin)
> > > +             if (!bin) {
> > > +                     v3d_job_put(&render->base);
> >
> > The job isn't initialized yet, this doesn't work.
> Do you mean we have to release render via kfree() here?
> 
> >
> > >                       return -ENOMEM;
> > > +             }
> > >
> > >               ret = v3d_job_init(v3d, file_priv, &bin->base,
> > >                                  v3d_job_free, args->in_sync_bcl);
> > >               if (ret) {
> > >                       v3d_job_put(&render->base);
> >
> > v3d_job_put will call kfree, if you chase the callchain long enough (in
> > v3d_job_free). So no bug here, this would lead to a double kfree and
> > crash.
> Yes, v3d_job_put() takes care of render,
> 
> > -Daniel
> >
> > > +                     kfree(bin);
> but how about leaking bin?

Sorry, I totally missed that this is bin, no render. Patch looks correct
to me.

Reviewed-by: Daniel Vetter <daniel.vetter@...ll.ch>

> 
> > >                       return ret;
> > >               }
> > >
> > > --
> > > 2.17.1
> > >
> >
> > --
> > Daniel Vetter
> > Software Engineer, Intel Corporation
> > http://blog.ffwll.ch
> 
> 
> 
> -- 
> Navid.

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ