From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796383535; b=hM2fU7e1xBv4IZUsRJ6JVjFoxHVfriIM7CoTg8hy0y2MXzFl1+/6Bfa6EYbPFXK6dq5Q O8+HPVnAYjYTjc9/z93oGWObTpxLt/QOZwS8q5++JlCRIKvB3lTBRpDIHaKHHjORdNa2k SaeBrbCmjGLlrEgnCZ4Uc4/GFbrebO5pZncA8mNS+D6d31S3DVTx6QlOeglsJ/QCiiYLQ 2cQd4FSIot0Uu4902HyeTjF6+hgCrjLGFIvRiczM2lVLmiN1E8tU7xIuDycBgMNEtmPk9 QJJI3D3516ehp4BtghaBmR/KFSNcjlvKiauPUWPnbruoNi3hzxNqTquc/DQPj+YRT/w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383535; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=4xTFvqpHjDZcOjhETmZXs6yDzGx5fcC1JKZ7kgnJoL8=; b=EFQMHlA9uQU2jp+2ofZidzy67dCOQpLTdE8JrMZLCqPUrvXGInzSmIRGs6nuXlgjTALN 6cxpig2oYefzpGVF0BSES7/zBu2HSG6B700yfcScfF3Wag3/5gQezmtnXmsBoXYdMVQDo TapKq0fEzYyHO305m8HJOJhSj+xdYGNreXgpCiE7uAruyMr7AykdzKLNXOrvS2LP6gwQg uLCJHBbDj/4+zx1a/4n4AfhCt83k28RtkYMA7wTzAVPgTP+QfGJLjAKc3LLN4PK5vSuVe ha4thd1BMLOZ6ytQiUoIy+PiIM/KE0l2Dn10BiPQB+A6gmgJEcE4Zu4/WpKavhTyaow== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=RuvxydcB; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A665D606A322; Fri, 4 Dec 2026 11:25:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=RuvxydcB Received: by smtp.kernel.org (Postfix) with ESMTPSA id 904AE1F00931; Fri, 4 Dec 2026 11:25:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383535; bh=4xTFvqpHjDZcOjhETmZXs6yDzGx5fcC1JKZ7kgnJoL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RuvxydcBb8fHyq71bLSHbOd/6j7LVJ1kpLTFkJLGQtEpcwGZ58pbzvdRPtguDq7CM zoTbSiEqIdxxduxCp4Q3lOYd6Mhu3winpgrgL4Xsrs50UZ6FnNDbRiPmXbwSqdNrhA 5OQH5CWvCvfkpAfe+Hfn0Qemi/3s/MXuilYDz+b0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Qu Wenruo , Filipe Manana , David Sterba , Sasha Levin Subject: [PATCH 6.12 262/555] btrfs: fiemap: deal with inline extent in fiemap_find_last_extent_offset() Date: Fri, 4 Dec 2026 19:05:05 +0900 Message-ID: <20261204100619.090868244@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Filipe Manana [ Upstream commit fd573263740371f76cad610cbcc70629b27f6c0c ] In the while loop that finds the first file extent item, counting from the end of the file, that is not a hole, we are accessing the disk_bytenr field of each file extent item, which is wrong in case we have an item that represents an inline extent. In that case the inline data starts at the disk_bytenr offset and therefore we are reading user data or in case the inline data is less than 8 bytes, we are accessing another region of the leaf or even beyond the leaf boundaries in case it's the last item. This should be a very rare case, as it implies having an inline extent followed by a hole file extent item (the no-holes feature is not used). Fixes: ac3c0d36a2a2 ("btrfs: make fiemap more efficient and accurate reporting extent sharedness") Reviewed-by: Qu Wenruo Signed-off-by: Filipe Manana Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/fiemap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/fiemap.c b/fs/btrfs/fiemap.c index cf93318d14080..e430d524365fc 100644 --- a/fs/btrfs/fiemap.c +++ b/fs/btrfs/fiemap.c @@ -621,6 +621,8 @@ static int fiemap_find_last_extent_offset(struct btrfs_inode *inode, leaf = path->nodes[0]; ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_file_extent_item); + if (btrfs_file_extent_type(leaf, ei) == BTRFS_FILE_EXTENT_INLINE) + break; disk_bytenr = btrfs_file_extent_disk_bytenr(leaf, ei); } -- 2.53.0