From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFCB44431 for ; Wed, 15 Mar 2023 12:39:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D4DCC433D2; Wed, 15 Mar 2023 12:39:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678883952; bh=QrgYTFN6a0sK1aeL38UN5CE8ytyWkS+uh7xojTl7gjU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zR7SiJ8qsjoNfPgqUdqoMEFLRhp35FNepJPwc0mCwcnGoI4jbHmW+5F2nmSWxoklb iibQJ0HWLNkaWCPxrBUq1rOWSWcnjce5l/c2C0JBgYsM5gZL21rIm5RYWeR9c16sKT 5ApCrenwoJhnviE713/o1YCZQ1LOapvOrhUYaaT0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jan Kara , Sasha Levin Subject: [PATCH 6.2 033/141] udf: Fix off-by-one error when discarding preallocation Date: Wed, 15 Mar 2023 13:12:16 +0100 Message-Id: <20230315115740.978486731@linuxfoundation.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230315115739.932786806@linuxfoundation.org> References: <20230315115739.932786806@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Jan Kara [ Upstream commit f54aa97fb7e5329a373f9df4e5e213ced4fc8759 ] The condition determining whether the preallocation can be used had an off-by-one error so we didn't discard preallocation when new allocation was just following it. This can then confuse code in inode_getblk(). CC: stable@vger.kernel.org Fixes: 16d055656814 ("udf: Discard preallocation before extending file with a hole") Signed-off-by: Jan Kara Signed-off-by: Sasha Levin --- fs/udf/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/udf/inode.c b/fs/udf/inode.c index a1af2c2e1c295..7faa0a5af0260 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -438,7 +438,7 @@ static int udf_get_block(struct inode *inode, sector_t block, * Block beyond EOF and prealloc extents? Just discard preallocation * as it is not useful and complicates things. */ - if (((loff_t)block) << inode->i_blkbits > iinfo->i_lenExtents) + if (((loff_t)block) << inode->i_blkbits >= iinfo->i_lenExtents) udf_discard_prealloc(inode); udf_clear_extent_cache(inode); phys = inode_getblk(inode, block, &err, &new); -- 2.39.2