From: Ursula Braun Date: Tue, 12 Nov 2019 15:03:41 +0000 (+0100) Subject: net/smc: fix refcount non-blocking connect() -part 2 X-Git-Tag: v5.3.12~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9932014fe3f9aae2190f92c12044d471641764fc;p=thirdparty%2Fkernel%2Fstable.git net/smc: fix refcount non-blocking connect() -part 2 [ Upstream commit 6d6dd528d5af05dc2d0c773951ed68d630a0c3f1 ] 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: syzbot+4b73ad6fc767e576e275@syzkaller.appspotmail.com Fixes: 301428ea3708 ("net/smc: fix refcounting for non-blocking connect()") Signed-off-by: Ursula Braun Signed-off-by: Karsten Graul Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index 5aec060a85811..737b49909a7af 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -796,6 +796,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; }