Commit 727b7e9a authored by Majd Dibbiny's avatar Majd Dibbiny Committed by Jason Gunthorpe

IB/core: Make sure that PSN does not overflow

The rq/sq->psn is 24 bits as defined in the IB spec, therefore we mask
out the 8 most significant bits to avoid overflow in modify_qp.
Signed-off-by: default avatarMajd Dibbiny <majd@mellanox.com>
Signed-off-by: default avatarDaniel Jurgens <danielj@mellanox.com>
Reviewed-by: default avatarParav Pandit <parav@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 2e903b61
...@@ -1320,6 +1320,7 @@ static int ib_resolve_eth_dmac(struct ib_device *device, ...@@ -1320,6 +1320,7 @@ static int ib_resolve_eth_dmac(struct ib_device *device,
int ib_modify_qp_with_udata(struct ib_qp *qp, struct ib_qp_attr *attr, int ib_modify_qp_with_udata(struct ib_qp *qp, struct ib_qp_attr *attr,
int attr_mask, struct ib_udata *udata) int attr_mask, struct ib_udata *udata)
{ {
u8 port = attr_mask & IB_QP_PORT ? attr->port_num : qp->port;
int ret; int ret;
if (attr_mask & IB_QP_AV) { if (attr_mask & IB_QP_AV) {
...@@ -1327,6 +1328,21 @@ int ib_modify_qp_with_udata(struct ib_qp *qp, struct ib_qp_attr *attr, ...@@ -1327,6 +1328,21 @@ int ib_modify_qp_with_udata(struct ib_qp *qp, struct ib_qp_attr *attr,
if (ret) if (ret)
return ret; return ret;
} }
if (rdma_ib_or_roce(qp->device, port)) {
if (attr_mask & IB_QP_RQ_PSN && attr->rq_psn & ~0xffffff) {
pr_warn("%s: %s rq_psn overflow, masking to 24 bits\n",
__func__, qp->device->name);
attr->rq_psn &= 0xffffff;
}
if (attr_mask & IB_QP_SQ_PSN && attr->sq_psn & ~0xffffff) {
pr_warn("%s: %s sq_psn overflow, masking to 24 bits\n",
__func__, qp->device->name);
attr->sq_psn &= 0xffffff;
}
}
ret = ib_security_modify_qp(qp, attr, attr_mask, udata); ret = ib_security_modify_qp(qp, attr, attr_mask, udata);
if (!ret && (attr_mask & IB_QP_PORT)) if (!ret && (attr_mask & IB_QP_PORT))
qp->port = attr->port_num; qp->port = attr->port_num;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment