Skip to content

Commit

Permalink
prov/sockets: set the domain for rx_ctrl_ctx
Browse files Browse the repository at this point in the history
The domain needs to be set for rx_ctrl_ctx as it can be accessed
by the following call chain:

1/ sock_pe_progress_tx_ctx()
2/ sock_pe_progress_rx_ctrl_ctx()
3/ sock_pe_progress_rx_pe_entry()
4/ sock_pe_process_recv()
5/ ock_pe_process_rx_read()
6/ Then sock_mr_verify_key() will segfault because rx_ctx->domain is set to NULL

Change-Id: I5ed3dbd2cf4483acbdfdd781692c09a261cd5198
  • Loading branch information
sydidelot committed Aug 3, 2017
1 parent 00b4103 commit a2a6874
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions prov/sockets/src/sock_ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,8 @@ static int sock_ep_tx_ctx(struct fid_ep *ep, int index, struct fi_tx_attr *attr,
tx_ctx->tx_id = index;
tx_ctx->ep_attr = sock_ep->attr;
tx_ctx->domain = sock_ep->attr->domain;
if (tx_ctx->rx_ctrl_ctx && tx_ctx->rx_ctrl_ctx->is_ctrl_ctx)
tx_ctx->rx_ctrl_ctx->domain = sock_ep->attr->domain;
tx_ctx->av = sock_ep->attr->av;
dlist_insert_tail(&sock_ep->attr->tx_ctx_entry, &tx_ctx->ep_list);

Expand Down Expand Up @@ -1252,6 +1254,9 @@ int sock_stx_ctx(struct fid_domain *domain,
return -FI_ENOMEM;

tx_ctx->domain = dom;
if (tx_ctx->rx_ctrl_ctx && tx_ctx->rx_ctrl_ctx->is_ctrl_ctx)
tx_ctx->rx_ctrl_ctx->domain = dom;

tx_ctx->fid.stx.fid.ops = &sock_ctx_ops;
tx_ctx->fid.stx.ops = &sock_ep_ops;
ofi_atomic_inc32(&dom->ref);
Expand Down Expand Up @@ -1731,6 +1736,8 @@ int sock_alloc_endpoint(struct fid_domain *domain, struct fi_info *info,
}
tx_ctx->ep_attr = sock_ep->attr;
tx_ctx->domain = sock_dom;
if (tx_ctx->rx_ctrl_ctx && tx_ctx->rx_ctrl_ctx->is_ctrl_ctx)
tx_ctx->rx_ctrl_ctx->domain = sock_dom;
tx_ctx->tx_id = 0;
dlist_insert_tail(&sock_ep->attr->tx_ctx_entry, &tx_ctx->ep_list);
sock_ep->attr->tx_array[0] = tx_ctx;
Expand Down

0 comments on commit a2a6874

Please sign in to comment.