]> git.baikalelectronics.ru Git - kernel.git/commit
net/smc: fix connection leak
authorD. Wythe <alibuda@linux.alibaba.com>
Thu, 24 Feb 2022 15:26:19 +0000 (23:26 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 25 Feb 2022 10:40:21 +0000 (10:40 +0000)
commit70bb9d3f0faf2c383f849b4272a1c9a584ead6ba
tree537718b9c30efa02e3a3d96b9c25f7c672d143f5
parent0eb3489a09521e19125579fec5fe95199105c8d9
net/smc: fix connection leak

There's a potential leak issue under following execution sequence :

smc_release   smc_connect_work
if (sk->sk_state == SMC_INIT)
send_clc_confirim
tcp_abort();
...
sk.sk_state = SMC_ACTIVE
smc_close_active
switch(sk->sk_state) {
...
case SMC_ACTIVE:
smc_close_final()
// then wait peer closed

Unfortunately, tcp_abort() may discard CLC CONFIRM messages that are
still in the tcp send buffer, in which case our connection token cannot
be delivered to the server side, which means that we cannot get a
passive close message at all. Therefore, it is impossible for the to be
disconnected at all.

This patch tries a very simple way to avoid this issue, once the state
has changed to SMC_ACTIVE after tcp_abort(), we can actively abort the
smc connection, considering that the state is SMC_INIT before
tcp_abort(), abandoning the complete disconnection process should not
cause too much problem.

In fact, this problem may exist as long as the CLC CONFIRM message is
not received by the server. Whether a timer should be added after
smc_close_final() needs to be discussed in the future. But even so, this
patch provides a faster release for connection in above case, it should
also be valuable.

Fixes: 7b71ec07a723 ("net/smc: common release code for non-accepted sockets")
Signed-off-by: D. Wythe <alibuda@linux.alibaba.com>
Acked-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/smc/af_smc.c