Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2882978rwb; Mon, 15 Aug 2022 13:15:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR4t6yieSlzTunTOAZ1T/l6kAgescnNEQj7QB7RtB2hil0bVNmfJbKtcdEqGWeGkY/dAbtXT X-Received: by 2002:a17:907:3f2a:b0:730:ec00:1b19 with SMTP id hq42-20020a1709073f2a00b00730ec001b19mr11674992ejc.722.1660594511827; Mon, 15 Aug 2022 13:15:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660594511; cv=none; d=google.com; s=arc-20160816; b=00G51T9GkEjrDccVCo21mCQWUJvUCbtmGMeC0wRqcVpGbMRxePwDLSqaFG7ltWfFGt LRX0eoAe9ubCsx4s8vYmgELNbr6cvLqJYomk8JTb7HiLvacWOUFPBeWLnX7zviMTdTnV FrLgGxOTlngHJt3QSjyYfzLSuEcgGiSkdqZ79DLVXW3Xhw4+NrLWHQ/mOGXQSw433KV0 A1YeMSdGrft64ULUItUzK4mXuy7Mh2SIuaB/G3w6vMOet7VktoF1ie38RIIRbSDKHp1U qy5v5YYWMcOS64BfE0z+WVawqkwoBbSRSggoHqO2xFgPc34DuBAcY6QqkiUUC9GmPc1b Kv6A== 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=YfE3RvLipjpbzTNxs/QDO1WN/36NaPT95+gLbQEXRWs=; b=zYgpHIOSzFC2wqVlKkAZOKp5E2pihqpKHRHr1e3fh0JxFpZ1EkEOO9T82HGLIlsIjJ G+qYsYDt2NIRqMDIPIGX41MvQTXhwaLnm0ReJ3CxF1KmDFzEdUakqO1o61Uue5KAl8YV Fjhp7rO7D2IpxjAaKRez6e4ofldxw2pYIuEWEXoa6dmjLy7oFxXKNFhDbZroftBk/XUj vNKipzc6hcPPsIjMZ29ZURWzkOmH6Pf13RQX8VxbW9g4u9CULcTjqxE5ZdY04ZhE6qph FyK1DBDNS3kD9KGqJiITSn5zKuuJiE18PnCpjJtpdWlhhcdG0DWTDqKV6jp7aI1LjwdN pkyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0PfbZ14k; 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 eh7-20020a0564020f8700b0043bd659930dsi7719299edb.523.2022.08.15.13.14.45; Mon, 15 Aug 2022 13:15:11 -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=0PfbZ14k; 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 S232797AbiHOT3r (ORCPT + 99 others); Mon, 15 Aug 2022 15:29:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343500AbiHOT0J (ORCPT ); Mon, 15 Aug 2022 15:26:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6541BF4C; Mon, 15 Aug 2022 11:41:32 -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 02F6061029; Mon, 15 Aug 2022 18:41:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3ABEC433D6; Mon, 15 Aug 2022 18:41:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660588891; bh=UEx6Vo839Re8ohZgQ30MADWOy3uPBUVXeG91KoZjUHI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0PfbZ14kBhfhrsc3HyaMYC1ZHcjFfvTq/jcd8KtDROBpl/xUczoRanqEkTJK0nZuv ntH7pJPGJzc4MjFamkJnwcHKR2jcTdLsTpLP+R02BPW89yOvPoC65vH3QJtaX/F54C Q7T6UXesPfVVsF6fXWcUEiPGAKoSVKdrTUrAHxtw= 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.15 547/779] block/rnbd-srv: Set keep_id to true after mutex_trylock Date: Mon, 15 Aug 2022 20:03:11 +0200 Message-Id: <20220815180400.696262812@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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 1ba1a93a6fe7..1896cde8135e 100644 --- a/drivers/block/rnbd/rnbd-srv.c +++ b/drivers/block/rnbd/rnbd-srv.c @@ -333,10 +333,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