Skip to contentSkip to conversation

net/smc: fix refcount non-blocking connect() -part 2

PATCH Applied Karsten Graul 2 participants 2 messages Nov 12, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/smc: fix refcount non-blocking connect() -part 2

From: Ursula Braun <[email protected]>

If an SMC socket is immediately terminated after a non-blocking connect() has been called, a memory leak is possible.
Due to the sock_hold move in
commit 301428ea3708 ("net/smc: fix refcounting for non-blocking connect()") an extra sock_put() is needed in smc_connect_work(), if the internal TCP socket is aborted and cancels the sk_stream_wait_connect() of the connect worker.

Reported-by [email protected]
Fixes 301428ea3708 ("net/smc: fix refcounting for non-blocking connect()")
---
 net/smc/af_smc.c | 1 +
 1 file changed, 1 insertion(+)
net/smc/af_smc.c +1 -0
index cde4dc0ed173..d0271bcb2191 100644
@@ -799,6 +799,7 @@ static void smc_connect_work(struct work_struct *work)
 			smc->sk.sk_err = EPIPE;
 		else if (signal_pending(current))
 			smc->sk.sk_err = -sock_intr_errno(timeo);
+		sock_put(&smc->sk); /* passive closing */
 		goto out;
 	}
 
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw

From: Karsten Graul <[email protected]>
Date: Tue, 12 Nov 2019 16:03:41 +0100

Quoted 10 lines

From: Ursula Braun <[email protected]>

If an SMC socket is immediately terminated after a non-blocking connect() has been called, a memory leak is possible.
Due to the sock_hold move in
commit 301428ea3708 ("net/smc: fix refcounting for non-blocking connect()") an extra sock_put() is needed in smc_connect_work(), if the internal TCP socket is aborted and cancels the sk_stream_wait_connect() of the connect worker.

Quoted 4 lines
Reported-by [email protected]
Fixes 301428ea3708 ("net/smc: fix refcounting for non-blocking connect()")

Applied.

And since 301428ea3708 went to -stable, I'll queue this up too.

Thanks.