Skip to content

Commit

Permalink
net/smc: use after free fix in smc_wr_tx_put_slot()
Browse files Browse the repository at this point in the history
[ Upstream commit e438bae43c1e08e688c09c410407b59fc1c173b4 ]

In smc_wr_tx_put_slot() field pend->idx is used after being
cleared. That means always idx 0 is cleared in the wr_tx_mask.
This results in a broken administration of available WR send
payload buffers.

Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Ursula Braun authored and gregkh committed Dec 17, 2019
1 parent 861e54e commit 7d04bd4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/smc/smc_wr.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,14 @@ int smc_wr_tx_put_slot(struct smc_link *link,

pend = container_of(wr_pend_priv, struct smc_wr_tx_pend, priv);
if (pend->idx < link->wr_tx_cnt) {
u32 idx = pend->idx;

/* clear the full struct smc_wr_tx_pend including .priv */
memset(&link->wr_tx_pends[pend->idx], 0,
sizeof(link->wr_tx_pends[pend->idx]));
memset(&link->wr_tx_bufs[pend->idx], 0,
sizeof(link->wr_tx_bufs[pend->idx]));
test_and_clear_bit(pend->idx, link->wr_tx_mask);
test_and_clear_bit(idx, link->wr_tx_mask);
return 1;
}

Expand Down

0 comments on commit 7d04bd4

Please sign in to comment.