Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2555962pxa; Mon, 17 Aug 2020 12:38:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrDeuJ/qbVBMKBn3euE6EZPnEaLvozXDtituweXfR+O4M0rbd0PSTS9TX/0n8AYv9eHmRR X-Received: by 2002:a17:907:204e:: with SMTP id pg14mr17286888ejb.324.1597693127465; Mon, 17 Aug 2020 12:38:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597693127; cv=none; d=google.com; s=arc-20160816; b=eE7BFu/LkDSRiLV1/nupTjiigc+QT/O24JXwi1lmqmsrxRXnC7+s4lz61p2jyQMQzi pNzaExLLVXj/dMApc1+HDZItxV2/Q5H0gBbeF99m9sdyG9ebx1EpWCqV7/hbPbwMv2N4 txVvRVEh4dK/pHZqLSwCdHFjzMZ1BsLmFZzaySWLX/VeK0TDV9KgPgqV9rkdwh8exJsY m++MwDJXchYxRrMk0MhktrY1k93P0wQnny6EgqPGftykzkxXjz/JAT/zKVyJ/1P5XKuV n1lf3RTXOLFhQTys5npDDGBTrJksrUS5kR2kNzlNxkk6BEl1F09nCMBkF8VF9MJV58BM ysxw== 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=5sOVcQw2TLaJphgvZoV0ZIunp/vwRxU1pWWeRqCFssg=; b=TaSc2zJ/nkvfgJ36mdDq6gW/oBrxvLV5L1WpL+S415ASNuhiMNvWgCZOa6/bDZVdWv N0p55LLON5n6xMxjwMnRi26OSrVu6R4GmmC6HJASXNLFdJQJ37KezmdpA8YpkQ9J5bcn NXnOugaAhJqLEiMXPbXSd2DsyNloy+lD30bjWyYJ9qIy9/XjnXuRDunGNqXXVzkl7U5F IH8ZpgThuQzmgo8bRG5ixvgb6SoazdaJQEorDECXw4zwVw7OB/XJqOrByWHoMYXr3HCL HvJ5qA8LXypadxXSIkLU1keq40WSWFcUpQ6YNFik3Qfy8UEvTnNeWXWtXlP5tQy/IhjH bkTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SenPNbw+; 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 r10si11418737ejs.554.2020.08.17.12.38.24; Mon, 17 Aug 2020 12:38:47 -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=SenPNbw+; 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 S1732392AbgHQTgw (ORCPT + 99 others); Mon, 17 Aug 2020 15:36:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:42048 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730011AbgHQP2M (ORCPT ); Mon, 17 Aug 2020 11:28:12 -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 791C423A32; Mon, 17 Aug 2020 15:28:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597678092; bh=Hxk7UHen0BwilFAy+VLDUeF9jJ/l/efGTHNGUWn3nYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SenPNbw+mxoN8HFoIjd0QgzI5nlNp7+4Z+vunA+URdYkDFf/MKAA3olhPBzWPWung tMCOtE8tpdsaxTb374Qoe9O4seG954E52X/4CkSI4P0GWPaGkbPySM6+eWvm/9oNwf NY6Uc5GLKvq7z/CW46pBZFMh+v56tjhKiX5J6w10= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andreas Gruenbacher , Christoph Hellwig , "Darrick J. Wong" , Sasha Levin Subject: [PATCH 5.8 214/464] iomap: Make sure iomap_end is called after iomap_begin Date: Mon, 17 Aug 2020 17:12:47 +0200 Message-Id: <20200817143844.062314049@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143833.737102804@linuxfoundation.org> References: <20200817143833.737102804@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: Andreas Gruenbacher [ Upstream commit 856473cd5d17dbbf3055710857c67a4af6d9fcc0 ] Make sure iomap_end is always called when iomap_begin succeeds. Without this fix, iomap_end won't be called when a filesystem's iomap_begin operation returns an invalid mapping, bypassing any unlocking done in iomap_end. With this fix, the unlocking will still happen. This bug was found by Bob Peterson during code review. It's unlikely that such iomap_begin bugs will survive to affect users, so backporting this fix seems unnecessary. Fixes: ae259a9c8593 ("fs: introduce iomap infrastructure") Signed-off-by: Andreas Gruenbacher Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Sasha Levin --- fs/iomap/apply.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/fs/iomap/apply.c b/fs/iomap/apply.c index 76925b40b5fd2..26ab6563181fc 100644 --- a/fs/iomap/apply.c +++ b/fs/iomap/apply.c @@ -46,10 +46,14 @@ iomap_apply(struct inode *inode, loff_t pos, loff_t length, unsigned flags, ret = ops->iomap_begin(inode, pos, length, flags, &iomap, &srcmap); if (ret) return ret; - if (WARN_ON(iomap.offset > pos)) - return -EIO; - if (WARN_ON(iomap.length == 0)) - return -EIO; + if (WARN_ON(iomap.offset > pos)) { + written = -EIO; + goto out; + } + if (WARN_ON(iomap.length == 0)) { + written = -EIO; + goto out; + } trace_iomap_apply_dstmap(inode, &iomap); if (srcmap.type != IOMAP_HOLE) @@ -80,6 +84,7 @@ iomap_apply(struct inode *inode, loff_t pos, loff_t length, unsigned flags, written = actor(inode, pos, length, data, &iomap, srcmap.type != IOMAP_HOLE ? &srcmap : &iomap); +out: /* * Now the data has been copied, commit the range we've copied. This * should not fail unless the filesystem has had a fatal error. -- 2.25.1