Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3022191rwb; Mon, 15 Aug 2022 16:19:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR4yW93EFQcYzZGphVfczNn+v9erIf+3UFwq0vYnf8Z9dhf4TiZe2F6+4srroGSg5yabK3M0 X-Received: by 2002:a05:6a00:27a9:b0:531:cec:5d2 with SMTP id bd41-20020a056a0027a900b005310cec05d2mr18344069pfb.42.1660605580944; Mon, 15 Aug 2022 16:19:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605580; cv=none; d=google.com; s=arc-20160816; b=RL34vhwh14OCDUZBGOO8ZRnxezFM3dOKRcCZwyr5A60nxdrSuOpxja143CLSXPb3N5 eTIMWjyQ313AuH0Ol3bsBrRKAUkdNYVj4u89MR2Gt0SdkERW86xp6Zavs0kHZpbGS/2O W5sgsbY8+UGKaTDr+qLlFUmLJKoBZk2VTBOjEH7qfQprFU7M5w0+nG81WRjMm2kSWmJc eRxflkhPLnN+6uhwSSknT0BJSq5erxK5LL3fWU6So7gT5imrx0Vdj1Mw881fH4TPTK76 i0sm5wsnKiJzSBMAWgQaiXbW14epKa1e1kee7632p2/MWI8eCALigmmTR8Rdgi0IPYI9 yzqw== 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=aM72rFJDlFqHLyKB5y60+UPN70IqtI6ihlZyS8+/NW8=; b=GhJqOOJx1Tm3k6YDG7Oovwdj0itRRyMqEPQue8IQ5RO9zTDkQqEM95R2sY8USWj29v uwC5Fsi27qy2890yPXphmmlwIwA92RaWMU9Q5+l6Mp03oJ3Xyj14zP0PVl9Hy5SzY3z0 8aOWsG6pdKqY7Wk301XN0lFe+pte3Aj/Pbpw80INO+d/Jdaeu50E6Vl8YzT5aBU1WnIQ RRT/vfVt9+eT5MU5q2of3AiljXwFcxhqTa6HOMtj/kOnlYleWM+z/QerVX+fICSDBaDv LsDcARy7h+WFaJAl6D2uBfn9ltAZZ4tcFzyQ2u3QjBsBSxJe43ZTW1G3fj9QN2BP0+U0 UsOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ToGX5moX; 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 9-20020a170902c20900b0016ef52684e5si10928037pll.149.2022.08.15.16.19.30; Mon, 15 Aug 2022 16:19:40 -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=ToGX5moX; 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 S1350930AbiHOW1T (ORCPT + 99 others); Mon, 15 Aug 2022 18:27:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348580AbiHOWVH (ORCPT ); Mon, 15 Aug 2022 18:21:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3E759C1D2; Mon, 15 Aug 2022 12:43:29 -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 80385610A5; Mon, 15 Aug 2022 19:43:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E529C433D7; Mon, 15 Aug 2022 19:43:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592607; bh=ErbsKZxnDc5fVV4xmCNmb6Y35Kw1T5Me4AnGUm3Btvo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ToGX5moX7Ytbwz86tQJFs5dmR2UmkMknmj5j51n1tgXJAg23FgQDdmw6A8cTsJAJJ eTn1qPzN8Ifg2cBB2N7LyPqpZG3r7eMu9bHKUQG1e5gklBtu+Q/i651ozDbZOhnrOo kmwVx+Y8f+4XTfAhlwMkVdafs9Xy8Ys/e9lDTLVw= 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.18 0815/1095] block/rnbd-srv: Set keep_id to true after mutex_trylock Date: Mon, 15 Aug 2022 20:03:34 +0200 Message-Id: <20220815180503.001150701@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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 f04df6294650..963df70ea026 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