public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net/smc: postpone sk_refcnt increment in connect()
@ 2022-05-23  3:24 liuyacan
  2022-05-23  4:57 ` [PATCH v2 " liuyacan
  0 siblings, 1 reply; 10+ messages in thread
From: liuyacan @ 2022-05-23  3:24 UTC (permalink / raw)
  To: kgraul, davem, edumazet, kuba, pabeni
  Cc: linux-s390, netdev, linux-kernel, ubraun, liuyacan

From: liuyacan <liuyacan@corp.netease.com>

Same trigger condition as commit 86434744. When setsockopt runs
in parallel to a connect(), and switch the socket into fallback
mode. Then the sk_refcnt is incremented in smc_connect(), but
its state stay in SMC_INIT (NOT SMC_ACTIVE). This cause the
corresponding sk_refcnt decrement in __smc_release() will not be
performed.

Signed-off-by: liuyacan <liuyacan@corp.netease.com>
Fixes: 86434744 ("net/smc: add fallback check to connect()")
---
 net/smc/af_smc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index fce16b9d6..45a24d242 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -1564,9 +1564,9 @@ static int smc_connect(struct socket *sock, struct sockaddr *addr,
 	if (rc && rc != -EINPROGRESS)
 		goto out;
 
-	sock_hold(&smc->sk); /* sock put in passive closing */
 	if (smc->use_fallback)
 		goto out;
+	sock_hold(&smc->sk); /* sock put in passive closing */
 	if (flags & O_NONBLOCK) {
 		if (queue_work(smc_hs_wq, &smc->connect_work))
 			smc->connect_nonblock = 1;
-- 
2.20.1


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

end of thread, other threads:[~2022-05-24 12:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-23  3:24 [PATCH net] net/smc: postpone sk_refcnt increment in connect() liuyacan
2022-05-23  4:57 ` [PATCH v2 " liuyacan
2022-05-23  9:10   ` patchwork-bot+netdevbpf
2022-05-23 12:45   ` Karsten Graul
2022-05-23 14:19     ` liuyacan
2022-05-23 14:44       ` Karsten Graul
2022-05-23 15:21         ` liuyacan
2022-05-24 11:43           ` Tony Lu
2022-05-24 12:11             ` liuyacan
2022-05-24 12:05           ` Karsten Graul

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