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=1793216475; b=JOBCk2UVDQtSP2zkfyiMUPNV6k1hlDMq+bUQuQpt9PRe6mb5eTCxWcPT0stf/eUEL/DQ GT+lPz+s1wMA4Ydg0zZT6HYPz9Vi7u2EPxlRiGEormMNxMqAcyRY+zuxCBQNsig+j3/R8 og+T7ii49i+X77YYRIf9eNoHj3Dl5dJT6El2jOcLQJVExDLChCgDLaIdGMauZNhcPpTxu WxVafFTeRJioYWAMP5XugwV7DK0GfHTQMqJakTI+7ZW//+7oE2HinU2KzNipJ7BH+Qt7l 9yPjhM3UwtnQxGm+Gltx+vToZrd+CqgF7ZCJo5BjgU9plt4XMC7mq+PyPFTA9BvXlnQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793216475; 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=HqkwRV0xW2DkuYxmFWik6Ij37iVpX1LDlDHWOMZj3iI=; b=Wq3BJ4IkvyfvTYB6SrmEOyUZ6EbeqIB6bhEJO/2ch+vJvV7SSYn98mnA1HFwwk9zq5XN AqNfmpM6kt3rZnCIVuDdu51huq2/QbYl5DwE2TqeBIU4D/l9q5dsf2sh9gh9RoTUHC+/J gyo8PKwXt+WVjHoSrhgjD+2DJgrdiP3A9W2ypoZvkUdbc6Gaj3AjNF48owwAnfYOp+RXa 0eXepS6F7JLkeWjtjbCxJMz/SljfkFsJCy2vZ+nNkFS+KfBJ+8mcvakJ/SVFfYbRAivMV nohx2rKUaJPayNDTWGeqWbLR3dhYZl7EJ51xQM5OiOD6vYYNXw2wO5MMoqOnHX8+/uQ== 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=BpVyARA3; 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 7091B606A31E; Wed, 28 Oct 2026 19:41:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=BpVyARA3 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 810581F01825; Wed, 28 Oct 2026 19:41:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1793216475; bh=HqkwRV0xW2DkuYxmFWik6Ij37iVpX1LDlDHWOMZj3iI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BpVyARA3iilhVHmw3njto7aaHvH7S2uAgXSU2VtdRzdYaaCpDlDVX6L+FKJ+pP+MA 1fCtT/BjKoYLfsqj8CTsTJjV6AoIqLnU/CvysC33UAk/gYssdtgM7AuKqECZAgFaZf HHjJPdao8qjf4uZR3NlPrzfY/Arya+MKxcGtmJJo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, ZhengYuan Huang , Joseph Qi , Mark Fasheh , Joel Becker , Junxiao Bi , Changwei Ge , Jun Piao , Heming Zhao , Andrew Morton , Sasha Levin Subject: [PATCH 6.1 1552/1887] ocfs2: validate orphan slot during inode read Date: Wed, 28 Oct 2026 18:00:48 +0100 Message-ID: <20261028170534.785362229@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261028170459.200466217@linuxfoundation.org> References: <20261028170459.200466217@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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: ZhengYuan Huang [ Upstream commit b2d31acbd3b182755b019183fb46949ba5e39b9f ] Patch series "ocfs2: validate active orphan slots during inode read". OCFS2 trusts active ordinary and append-DIO orphan slots read from dinodes. A corrupted slot can therefore index osb_orphan_wipes or the slot-local system-inode cache outside their allocations before the corruption is reported. Patch 1 validates the ordinary orphan slot used by inode wipe processing. Patch 2 validates the append-DIO orphan slot used by DIO completion and orphan recovery. Both checks reject corrupt metadata at the existing inode validation boundary. This patch (of 2): [BUG] A corrupted dinode with OCFS2_ORPHANED_FL can carry an i_orphaned_slot outside the mounted filesystem slot range. ocfs2_wipe_inode() uses it to index osb_orphan_wipes before looking up the orphan directory, causing an out-of-bounds memory access. BUG: KASAN: slab-use-after-free in ocfs2_get_system_file_inode+0x780/0x820 fs/ocfs2/sysfile.c:102 Read of size 8 at addr ffff88800b767c00 by task kworker/u8:3/85 Call Trace: ... ocfs2_get_system_file_inode+0x780/0x820 fs/ocfs2/sysfile.c:102 ocfs2_wipe_inode+0x292/0xf70 fs/ocfs2/inode.c:840 ocfs2_delete_inode fs/ocfs2/inode.c:1155 [inline] ocfs2_evict_inode+0x6c9/0x1170 fs/ocfs2/inode.c:1295 evict+0x38e/0x8f0 fs/inode.c:810 iput_final fs/inode.c:1914 [inline] iput fs/inode.c:1966 [inline] iput+0x55b/0x8b0 fs/inode.c:1926 ocfs2_recover_orphans+0x610/0xe40 fs/ocfs2/journal.c:2374 ocfs2_complete_recovery+0x5af/0xd00 fs/ocfs2/journal.c:1373 ... [CAUSE] ocfs2_validate_inode_block() validates i_suballoc_slot but leaves the active ordinary orphan slot unchecked. Downstream consumers assume that the value is smaller than osb->max_slots. [FIX] Reject an active i_orphaned_slot outside the slot range during dinode validation, before the inode reaches orphan wipe processing. Link: https://lore.kernel.org/20260803030007.3993199-1-gality369@gmail.com Link: https://lore.kernel.org/20260803030007.3993199-2-gality369@gmail.com Fixes: b4df6ed8db0c ("[PATCH] ocfs2: fix orphan recovery deadlock") Signed-off-by: ZhengYuan Huang Reviewed-by: Joseph Qi Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Cc: Changwei Ge Cc: Jun Piao Cc: Heming Zhao Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin --- fs/ocfs2/inode.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c index 8cd76357d3bf9..10c2759e16e85 100644 --- a/fs/ocfs2/inode.c +++ b/fs/ocfs2/inode.c @@ -1585,6 +1585,14 @@ int ocfs2_validate_inode_block(struct super_block *sb, goto bail; } + if ((le32_to_cpu(di->i_flags) & OCFS2_ORPHANED_FL) && + le16_to_cpu(di->i_orphaned_slot) >= OCFS2_SB(sb)->max_slots) { + rc = ocfs2_error(sb, "Invalid dinode %llu: orphaned slot %u\n", + (unsigned long long)bh->b_blocknr, + le16_to_cpu(di->i_orphaned_slot)); + goto bail; + } + if ((le32_to_cpu(di->i_flags) & OCFS2_DIO_ORPHANED_FL) && le16_to_cpu(di->i_dio_orphaned_slot) >= OCFS2_SB(sb)->max_slots) { rc = ocfs2_error(sb, "Invalid dinode %llu: DIO orphaned slot %u\n", -- 2.53.0