Re: [PATCH v2 2/2] RDMA/core: Initialize port_num in qp_attr

From: Kalderon, Michal
Date: Wed Jul 19 2017 - 11:09:16 EST


From: Ismail, Mustafa <mustafa.ismail@xxxxxxxxx>
Sent: Wednesday, July 19, 2017 5:38 PM

> > > > Fixes: 5ecce4c9b17b("Check port number supplied by user verbs cmds")
> > > > Cc: <stable@xxxxxxxxxxxxxxx> # v2.6.14+
> > > > Reviewed-by: Steve Wise <swise@xxxxxxxxxxxxxxxxxxxxx>
> > > > Signed-off-by: Mustafa Ismail <mustafa.ismail@xxxxxxxxx>
> > >
> > Why is the second patch required if you only validate the port_num if the
> > IB_QP_PORT mask is on?
> > Given the first patch [PATCH v2 1/2] RDMA/uverbs: Fix the check for port
> > number, this one seems redundant.
> Strictly speaking it is not required, but we felt it safer to always return a valid port number
> as is done in the IB case.

It's not always initialized in the IB case either. More than that if at this point you'll
initialize it for ib as well you'll get a failure on ib_modify_qp_is_ok, since when
transitioning to RTR / RTS providing IB_QP_PORT is not a valid option.
We actually hit this issue when running rping over RoCE. (prior to your fix i mean )
I agree that in general there's no real harm, but it seems a bit out of context, and if we
make the change common for ib/iwarp we'll have to modify ib_modify_qp_is_ok which
is written close to the spec.

thanks,
Michal