From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 34D6023395F for ; Mon, 3 Aug 2026 03:00:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785726054; cv=none; b=ZOC/kUR3/cSbQOPw3ZE/KMRU2/8dUzppNdSr1Uq9xuDOK+92TOO7T29RNQUEf0tBC1KtQdKZ7IuzMiLOc8OSmyshAWjrH3xX4YkhJdhk35iKyRfe+YjXqPxOlwi4OYe8dijMvboE8aualEX5Y6VMSyRnkWqr3ej7LOIbn51iATU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785726054; c=relaxed/simple; bh=xCj9Wo0LyTH8jhmyJf20NsQdndMxCAqsBnt9oKDNl5Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VJ85tTemTRjKBDx7QYyOTazUlLnnWswvi4WgVTWauGeprmQAROFaS5Y5Zb4E7kkKLLih0FwoU3Gx4XqdpkEb7Ll7PDqWGinIIVHpm46OllQ5+ED9sE2+4sbST1DO3Jn9ZZf8qtsdqHAkcOEzb2lJv9f2GIkW3RekGv2+KUdaazU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NvUokRil; arc=none smtp.client-ip=209.85.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NvUokRil" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-8486672f03cso3230267b3a.0 for ; Sun, 02 Aug 2026 20:00:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785726052; x=1786330852; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=VWJ8xLFcXVUc0SNvEud0LPLdtHNvViXl8nMczowYX88=; b=NvUokRilXKbxouN81sg826WmG/AypNQVYQdr5OQdgMpS2Zf84dAnBOLQBjsSLk89f/ ZtDtldxATBXFWsKk+5lF/WdAXeZUfNy7vp5x6aERVfz4xWJAxWA0a1Aa80B0tPJSfrnN Q7FbdMdBoJ9NV7RD1mJOULjrRSC9gbjXFWKl83hnOnVbHinKPe7iclFcJyvBZaXm3cd3 bAFKvDlVOOr7Pdo55EVDI+6Zq6AAvla7gsqov3tGD9s7Ob8C3Vj3MCNTz5Wk0xmC1JEg 9CsP9I4gYgAa0JWjuFoKzRQ5o1mGm+PPm0AMvV0/0YowsHYRGjp/Yb0RL6jgPDJzsd/i r+sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785726052; x=1786330852; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=VWJ8xLFcXVUc0SNvEud0LPLdtHNvViXl8nMczowYX88=; b=HzkajpcWC2yh3Gk1BINTx2wkevhcQkuXINfGvnoBxCfFmgHtRa81DyzJL+6X54FyIA WkRCOI7mWXJT811KqSjADMLrRXJAEu3AM6+L/nl9QIfu37Os3BZ6Sj9YDbRhNdHQwYkC hVyJIIv3HZQft342PReq99qpzKCsx8HybMl+j1VZ3ZvzCWtkbqBfPQQbRtPgWzUA3s2W 38YYvhX+fXD+b9Gh0UNZcsPnymyjEZBjYkbhsPattmP/lhf2g20AQbckPju6gG7tAQvv wHdasMLdeGz/UQLBiWGrhPTO4mTTj2czGcjlhWTltix4DEyv1KkLNobFnKA8haCLQML2 zO7A== X-Forwarded-Encrypted: i=1; AHgh+RosFBExeIcLPwjqHRGyyzl1jJXPISf0M+o7AHJCUUVOmgsxfdSn57gLlw0PZbkzKD2iq68vl6g1KXS4lg0=@vger.kernel.org X-Gm-Message-State: AOJu0YxA0X5jcndjhZNiKE5HLB/BS19Ws76U0ZNnIlY0AGO1RAszFp8F mdEZV0weIK0yCFTV5DfQJpb/XbIZDOydh7DV8nRc65QcIeLUoolF1zmC X-Gm-Gg: AR+sD10jYcJDDfpin6T0pFlWh3PhdLqINAsBFTavox5sGvikrybEiBesTOVhq4hC6iv R/VTcQ/JVgkVCSfhq1c3hif++0jDIr2kQDGvibA4g1JBbIecXALqECClyBGtOcQzATxU6ewSR+R yKftiqtu+LeQUEp4tz8LAmHb89JzbnJH0VJ6KK30eaq+N/WgBaU0JL3nSKgPBSPvS1zQFumG96R A2UouIfItri9+UPOfsydTmculB7qwe8d2XwFIVGVBnBjoArW0PPyA1ZtHS7sTKS3xk7pEmfEfgn E71oR2KASTE+I51hkRQBV8dLP00govhjTk3ncpo7lLOCBOrLVFIJB0NoQInklmUeJNfnahUnNeo zmGVhKg4HNnkFNIIQ3VTUN6w6Xr++HTy7DEh2iiWCS0wukvzZ7UY8G0U0xuU+DC1oBzCMVBBVsd m0Fc08tKOl8JQEt0TlNZmOoje7/alL6HZc3fT5D6C60m82u98du4m1oYRW0LRgZmyK7KpfUPwiw F1p9E0xIpEnDnr7COGJ5LMe1bbyHcZFhyTv3wrk X-Received: by 2002:a05:6a00:2788:b0:847:b16b:46d9 with SMTP id d2e1a72fcca58-84ee4851d1fmr7449689b3a.34.1785726052315; Sun, 02 Aug 2026 20:00:52 -0700 (PDT) Received: from gmail.com ([138.199.21.246]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84edc29f2b9sm2962878b3a.35.2026.08.02.20.00.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Aug 2026 20:00:51 -0700 (PDT) From: ZhengYuan Huang To: mark@fasheh.com, jlbec@evilplan.org, joseph.qi@linux.alibaba.com, akpm@linux-foundation.org Cc: ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org, baijiaju1990@gmail.com, r33s3n6@gmail.com, zzzccc427@gmail.com, tom442288@tuta.io, ZhengYuan Huang Subject: [PATCH 2/2] ocfs2: validate DIO orphan slot during inode read Date: Mon, 3 Aug 2026 11:00:07 +0800 Message-ID: <20260803030007.3993199-3-gality369@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260803030007.3993199-1-gality369@gmail.com> References: <20260803030007.3993199-1-gality369@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit [BUG] A corrupted append-DIO dinode (high byte at offset 0xa1 corrupted from 0 to 1) can carry an i_dio_orphaned_slot outside the mounted filesystem slot range and trigger a use-after-free error: 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_del_inode_from_orphan() uses i_dio_orphaned_slot to index the slot-local system inode cache. The dinode validator does not check this active slot, so an out-of-range value produces an invalid cache entry pointer that is dereferenced as an inode pointer. [FIX] Reject an active i_dio_orphaned_slot outside the slot range during dinode validation, before DIO orphan recovery can consume it. Fixes: 06ee5c75b575 ("ocfs2: add functions to add and remove inode in orphan dir") Signed-off-by: ZhengYuan Huang --- fs/ocfs2/inode.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c index 358ab3535366..180107a11046 100644 --- a/fs/ocfs2/inode.c +++ b/fs/ocfs2/inode.c @@ -1536,6 +1536,14 @@ int ocfs2_validate_inode_block(struct super_block *sb, 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", + (unsigned long long)bh->b_blocknr, + le16_to_cpu(di->i_dio_orphaned_slot)); + goto bail; + } + /* * Reject dinodes whose i_mode does not name one of the seven * canonical POSIX file types. ocfs2_populate_inode() copies -- 2.43.0