Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4142394pxb; Mon, 27 Sep 2021 10:14:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJpEbwDlzDGWdJsxwrwXivKm9qnatD3DX5B62V/aVbNIDIzDwRKd0DRdba1V430djOIRI5 X-Received: by 2002:a62:1b08:0:b0:43e:88f8:8f5e with SMTP id b8-20020a621b08000000b0043e88f88f5emr969371pfb.41.1632762877444; Mon, 27 Sep 2021 10:14:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632762877; cv=none; d=google.com; s=arc-20160816; b=YOuIwIp5kwmMWTmJdPuFq9Bl6paKwe5hL32floZhTTyI3HaxemGDbJ2J6GoNmpi/Md TlZPdpF1zcvPocC7lyAgtijP7agbt33uMlXOvMudUHzoYOs9ncg9ovBwmik+QBzCzPRh n75kYM6Bui1f9ndK8rERhwDYfsFlmRuxtB17kIXQy6nCPghmCz2c3IT+tfxepjo5Wddx IgI2ZeOPJphpnwGyTfikdd1kECNYz2R0JeptzzwoHBnhihPnx5XbO3TiPRbRX3VM0nJQ dPkY8kjKKSTE4klk87AuJ8o9ZOleSA0uxiZq2K22uLB8ZN/YL6XObr9h7ykY8Qw03sLt zHFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zNQ83EzRve5lT4SsI8zZ/AnV5/K8TFYbKMVcZZ3Dw6c=; b=vm/4x3L7AaDk+LrgcELEeFp0+czs15BGu+iukvFAslEaS0g0WQWaA/Qu8/CIQpa15e lNvQdPxl0+4xT7dYg/qDdDKCGpjFHrtrZiWRWnBe2ZJ39xVFvZscSwagwv7c3a+pUfBK fKNy/NZMD23K2S+Uh9NhXzUfiuYlifhJSru3iX50k7ABBwSqkVv0fUV1pxGMrAuINLwU UyKQSI7dhZPLo5F0K49et8Tp2Pdk+794n0mPHuBiulolvpeEQLauGYQFN3pGzVwlPzXY Bx7ipl4tkiNptuvx8E9aUIb9gf8zh5CDBNBbqa+TlN4IsX0HvSnlGnvxhe/t0x8RkG0X 2icA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=s7daOOyZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m24si13166919pls.262.2021.09.27.10.14.24; Mon, 27 Sep 2021 10:14:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=s7daOOyZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236637AbhI0RM6 (ORCPT + 99 others); Mon, 27 Sep 2021 13:12:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:47110 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236219AbhI0RKy (ORCPT ); Mon, 27 Sep 2021 13:10:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 14D2D611C7; Mon, 27 Sep 2021 17:08:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632762489; bh=ZgwHAiEioHWm/9mu0jnjK8OLQry1F0AmOZJ1Ca+m56g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s7daOOyZQrsljPahZV12tqXHTo1Qhb0yk9JssrJcc/ZMYUMZ+1KvzNDlVhu1kiSdK izcQpMeMVLiCknAIbod9OyyL3kzgSkuo2XDyhG19h0xX7XFxSETusgE4dS2HFcC8WO CyzP4TSIZx9cI0t94WrcQRs5QrTTLV02KM5W+4A0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Karsten Graul , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 042/103] net/smc: fix workqueue leaked lock in smc_conn_abort_work Date: Mon, 27 Sep 2021 19:02:14 +0200 Message-Id: <20210927170227.199687390@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210927170225.702078779@linuxfoundation.org> References: <20210927170225.702078779@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Karsten Graul [ Upstream commit a18cee4791b1123d0a6579a7c89f4b87e48abe03 ] The abort_work is scheduled when a connection was detected to be out-of-sync after a link failure. The work calls smc_conn_kill(), which calls smc_close_active_abort() and that might end up calling smc_close_cancel_work(). smc_close_cancel_work() cancels any pending close_work and tx_work but needs to release the sock_lock before and acquires the sock_lock again afterwards. So when the sock_lock was NOT acquired before then it may be held after the abort_work completes. Thats why the sock_lock is acquired before the call to smc_conn_kill() in __smc_lgr_terminate(), but this is missing in smc_conn_abort_work(). Fix that by acquiring the sock_lock first and release it after the call to smc_conn_kill(). Fixes: b286a0651e44 ("net/smc: handle incoming CDC validation message") Signed-off-by: Karsten Graul Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/smc/smc_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c index af96f813c075..c491dd8e67cd 100644 --- a/net/smc/smc_core.c +++ b/net/smc/smc_core.c @@ -1089,7 +1089,9 @@ static void smc_conn_abort_work(struct work_struct *work) abort_work); struct smc_sock *smc = container_of(conn, struct smc_sock, conn); + lock_sock(&smc->sk); smc_conn_kill(conn, true); + release_sock(&smc->sk); sock_put(&smc->sk); /* sock_hold done by schedulers of abort_work */ } -- 2.33.0