lkml.org 
[lkml]   [2019]   [Nov]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.3 114/140] net/smc: fix refcounting for non-blocking connect()
    Date
    From: Ursula Braun <ubraun@linux.ibm.com>

    [ Upstream commit 301428ea3708188dc4a243e6e6b46c03b46a0fbc ]

    If a nonblocking socket is immediately closed after connect(),
    the connect worker may not have started. This results in a refcount
    problem, since sock_hold() is called from the connect worker.
    This patch moves the sock_hold in front of the connect worker
    scheduling.

    Reported-by: syzbot+4c063e6dea39e4b79f29@syzkaller.appspotmail.com
    Fixes: 50717a37db03 ("net/smc: nonblocking connect rework")
    Reviewed-by: Karsten Graul <kgraul@linux.ibm.com>
    Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    net/smc/af_smc.c | 4 ++--
    1 file changed, 2 insertions(+), 2 deletions(-)

    --- a/net/smc/af_smc.c
    +++ b/net/smc/af_smc.c
    @@ -707,8 +707,6 @@ static int __smc_connect(struct smc_sock
    int smc_type;
    int rc = 0;

    - sock_hold(&smc->sk); /* sock put in passive closing */
    -
    if (smc->use_fallback)
    return smc_connect_fallback(smc, smc->fallback_rsn);

    @@ -853,6 +851,8 @@ static int smc_connect(struct socket *so
    rc = kernel_connect(smc->clcsock, addr, alen, flags);
    if (rc && rc != -EINPROGRESS)
    goto out;
    +
    + sock_hold(&smc->sk); /* sock put in passive closing */
    if (flags & O_NONBLOCK) {
    if (schedule_work(&smc->connect_work))
    smc->connect_nonblock = 1;

    \
     
     \ /
      Last update: 2019-11-08 20:12    [W:2.614 / U:0.100 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site