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=1796380431; b=XSafDWm0GtqwNG4d5EARLAo6wG3bbSEh0ZQZOO+b0qw/M9/vjWUWfl+zwV7yu9edLIhB a8hmJyKtjXp26g/2pxbFXVJKt8wrSw/NLz/qdge70Jhwd4ZoFJ8Gn/lbXRLa5KhCMOwJt ZciMXjDQF/8/C3alTcaANXIQn3sg4qIzbgigHa9zpG9BpWttqCQ/gHjI6C9KTWUjYt60i AgURsXbmQ+Ii8YP/4wWqJVofgG2MoChwZo2cO/JM0hNB0a2Mha3wfnkVuzLxsKli11+Ze 8/gl+PxYWb8xts4cRe7AgBQOVa7tj36WPFFYHaXnGbkcEGL/35dLG1sQynH/Qa2m4BA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380431; 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=+3mqqL+OEyYdI1zF7z98RBkitgw8NSNkRG/ID37jtZU=; b=lB3mBf3Wv0uaTFZzj/GZdhg4ZV7q1+aTz1s8S9txl0R54xGWxfySaVUFbxOjYZQp5je2 gzZVpAgs9xXRMHOh7pxAueEVjI055/GGwsuOkyE3cLiufDG5WUDTIkWv55wtv7D4bfZQI FarPTy+Dtd/GHJMypFHur/8C5C7fEWd0KAundHI7QEU3UP0FqU6QEQc5xCeuHxYt/j/Q3 hKjBtGrxYkHHudMnAiK8vQSZBF6m+iL468JHrjwtAuOYNuIklLHy9qnG2jLvvAxAYgiSc /GNZw5ZsJUFXAdzqOuaCBii4iOwV1DH7TrmWD2d9AXBRrJ66C4uziWh5/pQRHuzqcsw== 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=LUPaf0bu; 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 D7769606A687; Fri, 4 Dec 2026 10:33:51 +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=LUPaf0bu Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B6401F000CE; Fri, 4 Dec 2026 10:33:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380431; bh=+3mqqL+OEyYdI1zF7z98RBkitgw8NSNkRG/ID37jtZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LUPaf0bun+all+KsJAPnv4Be4P7LNyYninuiDFVb0XbtVIP6oF/H3A7LRgSZoQu9k 2vVvFZv4DGINCnKnK4rDTRLfA4AURkbaBLUU5CjwpR8xts9rO2K5hYCHLDDwT4cKo5 AsLGz926GOhzBTCwM36L74qCc+V972tHHWOgiPl8= 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 7.3 220/742] btrfs: fiemap: deal with inline extent in fiemap_find_last_extent_offset() Date: Fri, 4 Dec 2026 19:01:24 +0900 Message-ID: <20261204100640.918449076@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-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 817171028413c..285398eb36dc1 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