Commit 35d5c8b8 authored by Kaike Wan's avatar Kaike Wan Committed by Doug Ledford

IB/hfi1: Unsafe PSN checking for TID RDMA READ Resp packet

When processing a TID RDMA READ RESP packet that causes KDETH EFLAGS
errors, the packet's IB PSN is checked against qp->s_last_psn and
qp->s_psn without the protection of qp->s_lock, which is not safe.

This patch fixes the issue by acquiring qp->s_lock first.

Fixes: 9905bf06 ("IB/hfi1: Add functions to receive TID RDMA READ response")
Cc: <stable@vger.kernel.org>
Reviewed-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: default avatarKaike Wan <kaike.wan@intel.com>
Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Link: https://lore.kernel.org/r/20190815192039.105923.7852.stgit@awfm-01.aw.intel.comSigned-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent d58c1834
...@@ -2687,12 +2687,12 @@ static bool handle_read_kdeth_eflags(struct hfi1_ctxtdata *rcd, ...@@ -2687,12 +2687,12 @@ static bool handle_read_kdeth_eflags(struct hfi1_ctxtdata *rcd,
u32 fpsn; u32 fpsn;
lockdep_assert_held(&qp->r_lock); lockdep_assert_held(&qp->r_lock);
spin_lock(&qp->s_lock);
/* If the psn is out of valid range, drop the packet */ /* If the psn is out of valid range, drop the packet */
if (cmp_psn(ibpsn, qp->s_last_psn) < 0 || if (cmp_psn(ibpsn, qp->s_last_psn) < 0 ||
cmp_psn(ibpsn, qp->s_psn) > 0) cmp_psn(ibpsn, qp->s_psn) > 0)
return ret; goto s_unlock;
spin_lock(&qp->s_lock);
/* /*
* Note that NAKs implicitly ACK outstanding SEND and RDMA write * Note that NAKs implicitly ACK outstanding SEND and RDMA write
* requests and implicitly NAK RDMA read and atomic requests issued * requests and implicitly NAK RDMA read and atomic requests issued
......
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