public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-next] RDMA/core: Check invalid QP state for ib_modify_qp_is_ok()
@ 2021-03-19  9:02 Weihang Li
  2021-03-20  9:34 ` Leon Romanovsky
  0 siblings, 1 reply; 8+ messages in thread
From: Weihang Li @ 2021-03-19  9:02 UTC (permalink / raw)
  To: dledford, jgg; +Cc: leon, linux-rdma, linuxarm

From: Xi Wang <wangxi11@huawei.com>

Out-of-bounds may occur in 'qp_state_table' when the caller passing wrong
QP state value.

Signed-off-by: Xi Wang <wangxi11@huawei.com>
Signed-off-by: Weihang Li <liweihang@huawei.com>
---
 drivers/infiniband/core/verbs.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 28464c5..66ba4e6 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -1613,6 +1613,10 @@ bool ib_modify_qp_is_ok(enum ib_qp_state cur_state, enum ib_qp_state next_state,
 	    cur_state != IB_QPS_SQD && cur_state != IB_QPS_SQE)
 		return false;
 
+	if (cur_state >= ARRAY_SIZE(qp_state_table) ||
+	    next_state >= ARRAY_SIZE(qp_state_table[0]))
+		return false;
+
 	if (!qp_state_table[cur_state][next_state].valid)
 		return false;
 
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-03-22  7:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-19  9:02 [PATCH for-next] RDMA/core: Check invalid QP state for ib_modify_qp_is_ok() Weihang Li
2021-03-20  9:34 ` Leon Romanovsky
2021-03-22  3:29   ` liweihang
2021-03-22  5:47     ` Leon Romanovsky
2021-03-22  6:21       ` liweihang
2021-03-22  7:11       ` liweihang
2021-03-22  7:28         ` Leon Romanovsky
2021-03-22  7:55           ` liweihang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox