net/smc: fix refcount non-blocking connect() -part 2
authorUrsula Braun <ubraun@linux.ibm.com>
Tue, 12 Nov 2019 15:03:41 +0000 (16:03 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 12 Nov 2019 20:15:29 +0000 (12:15 -0800)
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 <ubraun@linux.ibm.com>
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/smc/af_smc.c

index 47946f4..8edf161 100644 (file)
@@ -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;
        }