Skip to content

Commit d0e62bf

Browse files
hiqbal-ionosrleon
authored andcommitted
RDMA/rtrs-srv: Avoid null pointer deref during path establishment
For RTRS path establishment, RTRS client initiates and completes con_num of connections. After establishing all its connections, the information is exchanged between the client and server through the info_req message. During this exchange, it is essential that all connections have been established, and the state of the RTRS srv path is CONNECTED. So add these sanity checks, to make sure we detect and abort process in error scenarios to avoid null pointer deref. Signed-off-by: Md Haris Iqbal <[email protected]> Signed-off-by: Jack Wang <[email protected]> Signed-off-by: Grzegorz Prajsner <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Leon Romanovsky <[email protected]>
1 parent ff73958 commit d0e62bf

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

drivers/infiniband/ulp/rtrs/rtrs-srv.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -935,12 +935,11 @@ static void rtrs_srv_info_req_done(struct ib_cq *cq, struct ib_wc *wc)
935935
if (err)
936936
goto close;
937937

938-
out:
939938
rtrs_iu_free(iu, srv_path->s.dev->ib_dev, 1);
940939
return;
941940
close:
941+
rtrs_iu_free(iu, srv_path->s.dev->ib_dev, 1);
942942
close_path(srv_path);
943-
goto out;
944943
}
945944

946945
static int post_recv_info_req(struct rtrs_srv_con *con)
@@ -991,6 +990,16 @@ static int post_recv_path(struct rtrs_srv_path *srv_path)
991990
q_size = SERVICE_CON_QUEUE_DEPTH;
992991
else
993992
q_size = srv->queue_depth;
993+
if (srv_path->state != RTRS_SRV_CONNECTING) {
994+
rtrs_err(s, "Path state invalid. state %s\n",
995+
rtrs_srv_state_str(srv_path->state));
996+
return -EIO;
997+
}
998+
999+
if (!srv_path->s.con[cid]) {
1000+
rtrs_err(s, "Conn not set for %d\n", cid);
1001+
return -EIO;
1002+
}
9941003

9951004
err = post_recv_io(to_srv_con(srv_path->s.con[cid]), q_size);
9961005
if (err) {

0 commit comments

Comments
 (0)