Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3122395rwb; Mon, 15 Aug 2022 18:40:31 -0700 (PDT) X-Google-Smtp-Source: AA6agR5BDEwt7poqG6zSgOKTCmrHh7YX04VFz/eTxlxHp0DR/DXBRahSKhiLcd5Am8gWYScNhQi8 X-Received: by 2002:a17:907:7f0b:b0:731:b81a:1912 with SMTP id qf11-20020a1709077f0b00b00731b81a1912mr12126914ejc.8.1660614031472; Mon, 15 Aug 2022 18:40:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660614031; cv=none; d=google.com; s=arc-20160816; b=LMdGhWwQE9zd0O2auxw742kElwPrY+DDrsYBkdVzaGvG/nS5PHL3DDTdwMl5vZ9GEu 1q+nJ2jDGkjqMxvYDvhocYGP45Rb7/Zx1PZUkYIxtELfmFP1P/Nz7/+9YMTUKhbx6q0X gzpljyehx/bF2i222K29bBuSZVNJgb7GbHtjr/2Tqi/lAW9hoxT6eVGDe/p+VUdm7PWt r0jvYVlLAyVG1Z/q6X90sOqP/HwdNU4AFLk5/aJb+3tqeyn9xNkXlpgTFpl9vK1EcigM ixQof2HXTFSxpFk6DnSzr9w+kDX2Zbdjb4hbX+rNQ91xPCmAbUA6R7ZGgl6pwo9pjvpM K8Hg== 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=njw5ldHWe+Pcls8lDcPDG8KGAWAOH3DDz7zv5a1r4eI=; b=fQsm+bLc3mVgTTU0kI2ECS0+pKTqFnkLt9ii/cCd2THGrC0IJ2i/DOQlCI3wvljrB7 DKfIB1J8tT8OO+f6nFCsJUsfMyZSs92zkHO/PqN25BkiFj9ckzLrTzUr9kFDBp2Xlt09 3yfYKS0dKqh5syeI6Sqflyw6DwUChkyZi2gjtAIsaw0w1SQyqCtaRivTBtw6k5EzUWIg yZnUBbUvfF3ROuuaWc5XDB8HAnLLazCH7QPLe5L7NFS8Jc+TX1bHvAxqTzNYxb8o/B0o GVQsmMqUjWsKAsLcGbb/I4I1eicK8Xwv2Ir0F0GhHE2/p37L4OMCwc2e7PoIuyGXDIf5 ryAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aF5vSAkQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dp19-20020a170906c15300b00738346168dcsi6151231ejc.811.2022.08.15.18.40.05; Mon, 15 Aug 2022 18:40:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aF5vSAkQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S244485AbiHPAfV (ORCPT + 99 others); Mon, 15 Aug 2022 20:35:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354475AbiHPAbh (ORCPT ); Mon, 15 Aug 2022 20:31:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17C491863F4; Mon, 15 Aug 2022 13:36:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A6571611D2; Mon, 15 Aug 2022 20:36:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37631C433D6; Mon, 15 Aug 2022 20:36:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660595789; bh=SaEPwYx2ijtoy0c6+KKibgnQEVVb7+tcLnxELbgSUkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aF5vSAkQE9cxkNi+QDUe9fr1nzfxZ+1nL/hwjguuIGjVyntZOpLJMfKUHN2bgdh04 Em0APSZGuGNIwwN+RjG9UJPNjP2FVledm5MZaKQglu3wpCSdSlfhTMFU67PvRRNNrz km69/2aLs2twSeOO9gPILrkUhr5JvKmktzQleAzs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, gi-oh.kim@ionos.com, Md Haris Iqbal , Jack Wang , Jens Axboe , Sasha Levin Subject: [PATCH 5.19 0876/1157] block/rnbd-srv: Set keep_id to true after mutex_trylock Date: Mon, 15 Aug 2022 20:03:52 +0200 Message-Id: <20220815180514.498172914@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Md Haris Iqbal [ Upstream commit 4bc14f3101364877dd59085f39e068a2a7ec9f2d ] After setting keep_id if the mutex trylock fails, the keep_id stays set for the rest of the sess_dev lifetime. Therefore, set keep_id to true after mutex_trylock succeeds, so that a failure of trylock does'nt touch keep_id. Fixes: b168e1d85cf3 ("block/rnbd-srv: Prevent a deadlock generated by accessing sysfs in parallel") Cc: gi-oh.kim@ionos.com Signed-off-by: Md Haris Iqbal Signed-off-by: Jack Wang Link: https://lore.kernel.org/r/20220707143122.460362-2-haris.iqbal@ionos.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/block/rnbd/rnbd-srv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c index beaef43a67b9..cf9e29a08db2 100644 --- a/drivers/block/rnbd/rnbd-srv.c +++ b/drivers/block/rnbd/rnbd-srv.c @@ -323,10 +323,11 @@ void rnbd_srv_sess_dev_force_close(struct rnbd_srv_sess_dev *sess_dev, { struct rnbd_srv_session *sess = sess_dev->sess; - sess_dev->keep_id = true; /* It is already started to close by client's close message. */ if (!mutex_trylock(&sess->lock)) return; + + sess_dev->keep_id = true; /* first remove sysfs itself to avoid deadlock */ sysfs_remove_file_self(&sess_dev->kobj, &attr->attr); rnbd_srv_destroy_dev_session_sysfs(sess_dev); -- 2.35.1