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 3DE164431 for ; Wed, 15 Mar 2023 12:21:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7B20C433EF; Wed, 15 Mar 2023 12:21:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678882896; bh=nZiM7ujGz+VVNeHFSrcVcPw+dbp/E+rSK35/XOy2cyE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QZVaKvZ4R0fAVtxJDuq4JRrbbzP6ayugsYN6aGJiNWr1gs2vqXd4jvPEGKXVuRboH s+bpdBvbCdkrDd5V/xUxI2i7G3H23RYZlJ4wBt3KTo7SG5+A3dGhPCejMOzVN8SR3T F18A8E98k+AGvW6/vmzmZDqFv2UXudQaoZ/LdW04= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jan Kara , Sasha Levin Subject: [PATCH 5.10 013/104] udf: Fix off-by-one error when discarding preallocation Date: Wed, 15 Mar 2023 13:11:44 +0100 Message-Id: <20230315115732.583783982@linuxfoundation.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230315115731.942692602@linuxfoundation.org> References: <20230315115731.942692602@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 81876284a83c0..d114774ecdea8 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -442,7 +442,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