Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2657331pxa; Mon, 17 Aug 2020 15:43:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwT1eNhltRXiVMw9VUA4z0Pob5G2dOuiX1AvujFerPap/c/fbvfjCRV8I5siXCuvqf+ccsT X-Received: by 2002:a17:907:9e7:: with SMTP id ce7mr17198047ejc.12.1597704199636; Mon, 17 Aug 2020 15:43:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597704199; cv=none; d=google.com; s=arc-20160816; b=xvLNapUlhDQZxK76+NcHW15+mpOtuY/GUfFKXUj4B6IYYo+SeJcoF0VyklZ2bhrV7R J01SLc7oqNeoQM8H2DD3TqZWof1spBPhPFX6ZPwAU4OqE+WCUEJtxCstRiD/QRW5zvw9 i706QdWoczve3TnkKVKAQjBCWZCU+5YLZ3ev5zB2DrW/rfBHTLh2X/MrWjMyQtGMMxRj GH23zf6bSjxIMqM+SuLdcit+Jq1z+YZJMdkRI3BkOA5RZurBNsxhto/ypj4+y7hwy6iD a7JAerOBXBwRy7NSBQfm+Y/3xaLjYI1Dek8Uq8AwANagCyEAF6f576DY7j952FQfBqmT x/Vg== 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=+YnfGzpJ4v9PnqtMPiN9PkOIJg6/ONA/GQh59NJFnp4=; b=avj9PLg96OmHHsFQN6jLJcISFsF/7ESn19VRwdt28q6Q1nuZJB3TEvOMBU8qbj3qMJ gBZ5vrUTnjtsm2pac+vWXYxc9ToIFytxHj8hZ7voUpv/WA8rwF8BXOf1fMNVg8+6tOY2 UTM3FXb2b5ACjL8GE8JAIlIxrKL2Mh90te9Rl1HZdvgyPq+DVc+Pw7X27clb+HPWqwpt 96q3OQ3kK4LYdMl/H4UMF3atDaaVru4kVHLThFo/XGdEhHVAtydfknY04k0EDNFyCdUU 7gL9K75PCiRPDsgbtz4P/Inz9csxJq9TdDz53ylejCiJyZUsiXWR+tfkxBSNCp4lReQE +XmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="O5hqE/No"; 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=fail (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 k17si12614774eds.353.2020.08.17.15.42.56; Mon, 17 Aug 2020 15:43:19 -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=@kernel.org header.s=default header.b="O5hqE/No"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403837AbgHQSsP (ORCPT + 99 others); Mon, 17 Aug 2020 14:48:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:42956 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388018AbgHQPz2 (ORCPT ); Mon, 17 Aug 2020 11:55:28 -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 EC56420885; Mon, 17 Aug 2020 15:55:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597679715; bh=6M08l+qba3w1cnpo6A4R3/eEQ9w/R/WVzannPHL4M/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O5hqE/NocgARUI0Rj3unD4OGPfQnCjy4iLUMc8mx5oQz4PgAiAgA3AQfZrIcWpbFB eRCvXW9h4TCMhf+XDPyz3F/W4+TX0DmjXIFhzlu5w5Vh8XnCW+msi22bLev7siGzQ8 mUfjX3r9NDIDcbauAcq0hu16ibWnKRvHqMgNLmRE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Pavel Machek (CIP)" , Andrew Morton , Joseph Qi , Mark Fasheh , Joel Becker , Junxiao Bi , Changwei Ge , Gang He , Jun Piao , Linus Torvalds , Sasha Levin Subject: [PATCH 5.7 309/393] ocfs2: fix unbalanced locking Date: Mon, 17 Aug 2020 17:15:59 +0200 Message-Id: <20200817143834.600206769@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143819.579311991@linuxfoundation.org> References: <20200817143819.579311991@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: Pavel Machek [ Upstream commit 57c720d4144a9c2b88105c3e8f7b0e97e4b5cc93 ] Based on what fails, function can return with nfs_sync_rwlock either locked or unlocked. That can not be right. Always return with lock unlocked on error. Fixes: 4cd9973f9ff6 ("ocfs2: avoid inode removal while nfsd is accessing it") Signed-off-by: Pavel Machek (CIP) Signed-off-by: Andrew Morton Reviewed-by: Joseph Qi Reviewed-by: Andrew Morton Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Cc: Changwei Ge Cc: Gang He Cc: Jun Piao Link: http://lkml.kernel.org/r/20200724124443.GA28164@duo.ucw.cz Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/ocfs2/dlmglue.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index 751bc4dc74663..8e3a369086dbd 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c @@ -2871,9 +2871,15 @@ int ocfs2_nfs_sync_lock(struct ocfs2_super *osb, int ex) status = ocfs2_cluster_lock(osb, lockres, ex ? LKM_EXMODE : LKM_PRMODE, 0, 0); - if (status < 0) + if (status < 0) { mlog(ML_ERROR, "lock on nfs sync lock failed %d\n", status); + if (ex) + up_write(&osb->nfs_sync_rwlock); + else + up_read(&osb->nfs_sync_rwlock); + } + return status; } -- 2.25.1