Re: [PATCH] RDMA/ucma: Check for a cm_id->device in all user calls that need it

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 04, 2018 at 09:08:56AM +0300, Leon Romanovsky wrote:
> On Tue, Apr 03, 2018 at 09:07:41PM -0600, Jason Gunthorpe wrote:
> > This is done by auditing all callers of ucma_get_ctx and switching the
> > ones that unconditionally touch ->device to ucma_get_ctx_dev. This covers
> > a little less than  half of the call sites.
> >
> > The 11 remaining call sites to ucma_get_ctx() were manually audited.
> >
> > It looks like none of these cases cause bugs due to the FSM system
> > inside the CMA, but documenting the requirement and the result of this
> > audit is still productive.
> >
> > Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx>
> >  drivers/infiniband/core/ucma.c | 34 ++++++++++++++++++++++------------
> >  1 file changed, 22 insertions(+), 12 deletions(-)
> >
> > Inspired by Roland's patch, let us try hard to be sure we are done with
> > this issue.
> >
> > diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
> > index e74c82ee38a9f7..95e1eadae074ff 100644
> > +++ b/drivers/infiniband/core/ucma.c
> > @@ -153,6 +153,21 @@ static struct ucma_context *ucma_get_ctx(struct ucma_file *file, int id)
> >  	return ctx;
> >  }
> >
> > +/*
> > + * Same as ucm_get_ctx but requires that ->cm_id->device is valid, eg that the
> > + * CM_ID is bound.
> > + */
> > +static struct ucma_context *ucma_get_ctx_dev(struct ucma_file *file, int id)
> > +{
> > +	struct ucma_context *ctx = ucma_get_ctx(file, id);
> > +
> > +	if (IS_ERR(ctx))
> > +		return ctx;
> > +	if (!ctx->cm_id->device)
> > +		return ERR_PTR(-EINVAL);
> > +	return ctx;
> > +}
> 
> I like the idea, but the implementation needs to be improved a little bit.
> All old callers to ucma_get_ctx() expected that once that call fails
> they won't need to release "ctx". Now, the failures returned by ucma_get_ctx_dev()
> break that flow.

Oops, yes, thanks. v2 on its way

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux