Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp5854530ybn; Sun, 29 Sep 2019 07:07:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYA3tOkEy5vdOCCyxFMsd3R2HYixbPNBkJCVqura9KJdp8fLANmvZ1jyMfA22698/xH6gz X-Received: by 2002:a50:a57d:: with SMTP id z58mr14775141edb.115.1569766074157; Sun, 29 Sep 2019 07:07:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569766074; cv=none; d=google.com; s=arc-20160816; b=jh3iR5smaPw5RrYovhIWwwxVpfugoY78py809nVsVdy2NqKesm5W5VeUtXqExBs5qH Rza/4uzF7OnW+b3PpQ4H427sitAOC1vTZBoYI1WrGEFbq+zt/212nIQNvStf6vfn6Wsf nXgmGQuJlPdPzfYJVvbg/XvADGMoiMYtp+Dk3f7NZUZD5ujp8/pOf5/+sMGasaba0YGa MMucLgsNz5shOdefJgjpEx+q9igCgZJM4xiZnKNbILaMN5WLg4H/Qmo5fP04H+MkvIk7 9OnncJBhGNSwPJJd0XW/OH9bWEDgh9B8QIKySzR4Tjf3IoKNpslbeEWHPNIrEhwyOAe3 CKEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8kGhGVGzEMuk/SMWDt2/pH9nv/WsZJYtV4RTpu+G5Hs=; b=y1JV5sj7xQraAgccAZXAdh+cZFMEBPEznIh8ML1l1L4kryFXvBaHXEv9FAZe1Hg5gA gYUzDxHrblYfpD/xb9pLU/Ca3UosITEV/vn8kezx0F5+lRK+ZZhFl7vSiT7GG+n5h7BK r2fmNroiHODZoSRpKlkL7LJk/fcIzdkNROkHY2BWtrg4RmT/EJeK/Pw8L4HHLwYPd5Cu qTEBNG6RI8QXAalzS9B2dIasETq+vqq5aV3U0pbWWX7xqv8XC1W98yUfexDLjWt9Uy0K dvmTQzkwY+J87+FhuWyU/Sb8Cu47YlqmpF77TwncZyM985gE/FNrqxi6u24xobZK/U4d RwuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EdlqAz2M; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b21si5740971ejq.343.2019.09.29.07.07.29; Sun, 29 Sep 2019 07:07:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EdlqAz2M; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730003AbfI2OBQ (ORCPT + 99 others); Sun, 29 Sep 2019 10:01:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:43366 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729409AbfI2OBP (ORCPT ); Sun, 29 Sep 2019 10:01:15 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 61BEB2082F; Sun, 29 Sep 2019 14:01:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569765674; bh=QCc1+IZSJhTqcE8sJ998hMa8hSC03JMq+jgOzg9VnPo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EdlqAz2M9TthDRiuCeP6+Q8TFgrEm4q6B2lKtKwwVu8z4AuXp16Z/0qyyC3i05CEE OsTnH5zg5Qye893nKBrPHhzrBkZ+wtgweoExXvCFDdZFSo2em6IdPfztsAJL2luXXS abXeDVd3GegxW1k+FcK7KgBBXWYW0xJzHVTPrOPE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kbuild test robot , Dan Carpenter , Pavel Shilovsky , Steve French , Aurelien Aptel , Sasha Levin Subject: [PATCH 5.2 02/45] smb3: fix unmount hang in open_shroot Date: Sun, 29 Sep 2019 15:55:30 +0200 Message-Id: <20190929135025.151404151@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190929135024.387033930@linuxfoundation.org> References: <20190929135024.387033930@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Steve French [ Upstream commit 96d9f7ed00b86104bf03adeffc8980897e9694ab ] An earlier patch "CIFS: fix deadlock in cached root handling" did not completely address the deadlock in open_shroot. This patch addresses the deadlock. In testing the recent patch: smb3: improve handling of share deleted (and share recreated) we were able to reproduce the open_shroot deadlock to one of the target servers in unmount in a delete share scenario. Fixes: 7e5a70ad88b1e ("CIFS: fix deadlock in cached root handling") This is version 2 of this patch. An earlier version of this patch "smb3: fix unmount hang in open_shroot" had a problem found by Dan. Reported-by: kbuild test robot Reported-by: Dan Carpenter Suggested-by: Pavel Shilovsky Reviewed-by: Pavel Shilovsky Signed-off-by: Steve French CC: Aurelien Aptel CC: Stable Signed-off-by: Sasha Levin --- fs/cifs/smb2ops.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 42de31d206169..8ae8ef526b4a5 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -656,6 +656,15 @@ int open_shroot(unsigned int xid, struct cifs_tcon *tcon, struct cifs_fid *pfid) return 0; } + /* + * We do not hold the lock for the open because in case + * SMB2_open needs to reconnect, it will end up calling + * cifs_mark_open_files_invalid() which takes the lock again + * thus causing a deadlock + */ + + mutex_unlock(&tcon->crfid.fid_mutex); + if (smb3_encryption_required(tcon)) flags |= CIFS_TRANSFORM_REQ; @@ -677,7 +686,7 @@ int open_shroot(unsigned int xid, struct cifs_tcon *tcon, struct cifs_fid *pfid) rc = SMB2_open_init(tcon, &rqst[0], &oplock, &oparms, &utf16_path); if (rc) - goto oshr_exit; + goto oshr_free; smb2_set_next_command(tcon, &rqst[0]); memset(&qi_iov, 0, sizeof(qi_iov)); @@ -690,18 +699,10 @@ int open_shroot(unsigned int xid, struct cifs_tcon *tcon, struct cifs_fid *pfid) sizeof(struct smb2_file_all_info) + PATH_MAX * 2, 0, NULL); if (rc) - goto oshr_exit; + goto oshr_free; smb2_set_related(&rqst[1]); - /* - * We do not hold the lock for the open because in case - * SMB2_open needs to reconnect, it will end up calling - * cifs_mark_open_files_invalid() which takes the lock again - * thus causing a deadlock - */ - - mutex_unlock(&tcon->crfid.fid_mutex); rc = compound_send_recv(xid, ses, flags, 2, rqst, resp_buftype, rsp_iov); mutex_lock(&tcon->crfid.fid_mutex); -- 2.20.1