From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52854C7618A for ; Wed, 15 Mar 2023 12:41:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232974AbjCOMlf (ORCPT ); Wed, 15 Mar 2023 08:41:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232887AbjCOMlT (ORCPT ); Wed, 15 Mar 2023 08:41:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FC59132F6 for ; Wed, 15 Mar 2023 05:40:06 -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 1E94361D79 for ; Wed, 15 Mar 2023 12:39:13 +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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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