]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
tipc: fix wrong socket reference counter after tipc_sk_timeout() returns
authorTung Nguyen <tung.q.nguyen@dektech.com.au>
Thu, 28 Nov 2019 03:10:06 +0000 (10:10 +0700)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 6 Mar 2020 07:25:26 +0000 (02:25 -0500)
BugLink: https://bugs.launchpad.net/bugs/1864060
commit 91a4a3eb433e4d786420c41f3c08d1d16c605962 upstream.

When tipc_sk_timeout() is executed but user space is grabbing
ownership, this function rearms itself and returns. However, the
socket reference counter is not reduced. This causes potential
unexpected behavior.

This commit fixes it by calling sock_put() before tipc_sk_timeout()
returns in the above-mentioned case.

Fixes: afe8792fec69 ("tipc: refactor function tipc_sk_timeout()")
Signed-off-by: Tung Nguyen <tung.q.nguyen@dektech.com.au>
Acked-by: Ying Xue <ying.xue@windriver.com>
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
net/tipc/socket.c

index 016c1dfc8f0ef622ff20ca0d04df528025dde16c..b0ff9027f8d117f326dd9b6fe7ee170db73c1591 100644 (file)
@@ -2687,6 +2687,7 @@ static void tipc_sk_timeout(struct timer_list *t)
        if (sock_owned_by_user(sk)) {
                sk_reset_timer(sk, &sk->sk_timer, jiffies + HZ / 20);
                bh_unlock_sock(sk);
+               sock_put(sk);
                return;
        }