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]
Message-ID: <20190928060032.GJ14368@unreal>
Date:   Sat, 28 Sep 2019 09:00:32 +0300
From:   Leon Romanovsky <leon@...nel.org>
To:     "Saleem, Shiraz" <shiraz.saleem@...el.com>
Cc:     "Kirsher, Jeffrey T" <jeffrey.t.kirsher@...el.com>,
        "dledford@...hat.com" <dledford@...hat.com>,
        "jgg@...lanox.com" <jgg@...lanox.com>,
        "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
        "Ismail, Mustafa" <mustafa.ismail@...el.com>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "linux-rdma@...r.kernel.org" <linux-rdma@...r.kernel.org>
Subject: Re: [RFC 12/20] RDMA/irdma: Implement device supported verb APIs

On Fri, Sep 27, 2019 at 02:28:41PM +0000, Saleem, Shiraz wrote:
> > Subject: Re: [RFC 12/20] RDMA/irdma: Implement device supported verb APIs
> >
> > On Thu, Sep 26, 2019 at 07:49:52PM +0000, Saleem, Shiraz wrote:
> > > > Subject: Re: [RFC 12/20] RDMA/irdma: Implement device supported verb
> > > > APIs
> > > >
> > > > On Thu, Sep 26, 2019 at 09:45:11AM -0700, Jeff Kirsher wrote:
> > > > > From: Mustafa Ismail <mustafa.ismail@...el.com>
> > > > >
> > > > > Implement device supported verb APIs. The supported APIs vary
> > > > > based on the underlying transport the ibdev is registered as (i.e.
> > > > > iWARP or RoCEv2).
> > > > >
> > > > > Signed-off-by: Mustafa Ismail <mustafa.ismail@...el.com>
> > > > > Signed-off-by: Shiraz Saleem <shiraz.saleem@...el.com>
> > > > > ---
> > > > >  drivers/infiniband/hw/irdma/verbs.c      | 4346 ++++++++++++++++++++++
> > > > >  drivers/infiniband/hw/irdma/verbs.h      |  199 +
> > > > >  include/uapi/rdma/rdma_user_ioctl_cmds.h |    1 +
> > > > >  3 files changed, 4546 insertions(+)  create mode 100644
> > > > > drivers/infiniband/hw/irdma/verbs.c
> > > > >  create mode 100644 drivers/infiniband/hw/irdma/verbs.h
> > > > >
> > > > > diff --git a/drivers/infiniband/hw/irdma/verbs.c
> > > > > b/drivers/infiniband/hw/irdma/verbs.c
> > > > > new file mode 100644
> > > > > index 000000000000..025c21c722e2
> > > > > --- /dev/null
> > > > > +++ b/drivers/infiniband/hw/irdma/verbs.c
> > > > > @@ -0,0 +1,4346 @@
> > > > > +// SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB
> > > > > +/* Copyright (c) 2019, Intel Corporation. */
> > > >
> > > > <...>
> > > >
> > > > > +
> > > > > +	size = sqdepth * sizeof(struct irdma_sq_uk_wr_trk_info) +
> > > > > +	       (rqdepth << 3);
> > > > > +	iwqp->kqp.wrid_mem = kzalloc(size, GFP_KERNEL);
> > > > > +	if (!iwqp->kqp.wrid_mem)
> > > > > +		return -ENOMEM;
> > > > > +
> > > > > +	ukinfo->sq_wrtrk_array = (struct irdma_sq_uk_wr_trk_info *)
> > > > > +				 iwqp->kqp.wrid_mem;
> > > > > +	if (!ukinfo->sq_wrtrk_array)
> > > > > +		return -ENOMEM;
> > > >
> > > > You are leaking resources here, forgot to do proper error unwinding.
> > > >
> > >
> > > irdma_free_qp_rsrc() will free up that memory in case of an error.
> >
> > I'm talking about kqp.wrid_mem you allocated a couple of lines above and didn't
> > free in case of sq_wrtrk_array allocation failed.
> >
> Yes, I am referring to kqp.wrid_mem as well
> In case of err, all memory resources setup for
> the QP is freed in the common utility irdma_free_qp_rsrc()
> including the kqp.wrid_mem.

I see it as an anti-pattern, you have function to setup and it shouldn't
return half initialized state and rely on some other function to clean
the mess.

Current code is written in a way that makes very hard to check for
unwinding errors.

Thanks

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ