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=1796381982; b=0DkwqdoNEysq3Ij82evkSEjxjowcZn0Cf6SCzzb4bf/B8MEM/miiMdogDxv+PNGT3EZm D3NemDu7lXiNGeuJKtRNMDECVxY4j3U9NBvBJK+j5Xws/7NJ0MS1TWYNFjlXfCVUPKiZj CzXqD/9AHAO2oda7MtQmu4FQYb9tscnF/ae1z6hbSaYW/ghTntpZR1frtrD/hqwdu+6HC pbu1lIx87nkoeV407AZZng3dJfeS316IfFaP6s/g1/mb7/E3E5rDUM7eNgNOBexBBzARa FX7GoRVlYBwY+uBzMKUOOC7NolxbQMd+i7kB7xXzgDk3G7LNOdrRMfJAiOY1V1+ZLVg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381982; 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=PcFubkHO0m/gFWiW8wdxR/vjk1Iaeq4ti1Nag3OHRfE=; b=rkibPJk6M7/JbGdcfgGPWBALr4nZ7Fhl1egnj9HTT4ntGu5UiovfXaf9huS5ce2KLQJz t+enPgDp+3xZtPFTdfhFm9Bk2sIDkIJobhKQu/wOCGMNF+jciUlWz/FPksDVcJCx1pnw4 9FeChzZd3xFdiBBKeGIm6o6mTOc3xtg3lVImQWVN/s9vfQo5mUNATvGO3HxfhpI12Cauc 8dIKbL4WDoIfk783CcGIrxHSH5dmgC0y6Ljrr8IIX+D97pt875PEi/29DmHvqaCTfPtsH WOFI+zbLNi8nEAJ9QS1yWg6fyTuBHyhUVoyZ6pz77yd+6Ly0aVtQpBdxD4tFT3rAXQA== 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=thNUZ6jB; 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 022A3606A322; Fri, 4 Dec 2026 10:59:42 +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=thNUZ6jB Received: by smtp.kernel.org (Postfix) with ESMTPSA id 700391F000CE; Fri, 4 Dec 2026 10:59:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381981; bh=PcFubkHO0m/gFWiW8wdxR/vjk1Iaeq4ti1Nag3OHRfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=thNUZ6jBwNzOWbHJ+fqdq/beywpyq/hyvrHtjhM/hccR/UuNS8PM80XSR0slKF784 NtQaWblfLs2pEj1JjK8wdeVQKviB+pXS7UnYGCAhci598psXNJWYeTfGH0YZCHDwNI sQyIRRDol9MjGjYuIEoz+XDOom1joTAuY80ueMI0= 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.18 257/703] btrfs: fiemap: deal with inline extent in fiemap_find_last_extent_offset() Date: Fri, 4 Dec 2026 19:02:36 +0900 Message-ID: <20261204100634.631190270@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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.18-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 5fb7342a616d1..7bf95a295a00f 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