From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 5FD3F378D64 for ; Fri, 8 May 2026 08:59:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778230791; cv=none; b=qCdJM41J1yXOFvF7TytzKrFwdbZD8o0kuIxXpH3Wy37cA+5AEZA6g1HOiBSn2s0qE+HlDKsul7bGr98ApToJ93ZxXl5NV+gpUj2Af1XDGd/T+vh/0ZH//Qnfkj+I/R2+IDRTcK2Wz48BpVrLay45bxCvK63vC5a/hqH/wDYyWfo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778230791; c=relaxed/simple; bh=XZ2AxGd44BGqb6s1OpcbJ9fXbkAw+J5LMr3jUSfyuU8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Hr8+G6HNL7Eg/9X7C+51LO5choFs8k9upIgb8tzE6DRwGETQJLW5zrFOk0M4xjOVgvoRH3+tG9sv8n7YtMAa0va9rMSdL3SoHy+FIxMxDBESdXUkp530L/B0+YVrJLY1ipUmjjb96GZ386z6CTl9vA7jEdw9TGQ92QnMNWL6Wns= 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=sic2nLcW; arc=none smtp.client-ip=209.85.214.173 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="sic2nLcW" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2ba17c8cfacso17794585ad.2 for ; Fri, 08 May 2026 01:59:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778230790; x=1778835590; 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; bh=EUwXIfq13O1zgTkCmaAhWKKGGyYV15U86EllEIJj79E=; b=sic2nLcW472XoE8szx0Sy3aT+bDZDmNUtZw1zVhtFr3b+7EwWEYoAGPBkjznwhiUVP rAO2QEDDQKioBo1QOiK+ML9tGwqGKu246aEGRCWF2oQVZ3JC6pjSHoXUWxCWOMEeWpRQ 4B0mgVlXopyLsnYUgdYtToDmP1kgPbfM1v1rGNrWUcMlxLKXDEroY36poF6T+U6xPgBY CVkl4MLlscr3Fh00lh03zuWkFr3HkSH9q0u9r/Tzp6YCf/Pxs8n219Pz16HbW3cwzg+X IQFqiWe0LZpo74NOn3oKvJzGo7kc3WDcPxqAYVdMpIjuVjt0ARLjQ6wAhJe+KmfOV76V DQFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778230790; x=1778835590; 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; bh=EUwXIfq13O1zgTkCmaAhWKKGGyYV15U86EllEIJj79E=; b=ZtIoi4jeqhklebDLQgLG7a+FzP3zisLPOVB3x5zYPsbeSn+tRsNx8yPjiuPeYZTj+A ElDa2K3DWTK5J9pN6VJM9D6Swgwd315xzMfG20FTg0Pe2OB/ZhnwwnGpYGDZVynaPqW/ iH/5SBEEf+YW2w2cdncXqL8yI06H1gsk9Bs93DCHlCbrU4clbFQlDT0LRCHatRw/Jb9L aLcy84QYtG2yiFjhXyN5Y+NYYiXiVUVPDRzNDLL5De2lLwSZ30RcaU0lul7gMf466K9J FuPRSYG6T3FtXuSbgVrezYm2al1CGx54hrxavsVc1u/AQXsJj1IE78VApVpz2gCX2FJS pTRQ== X-Forwarded-Encrypted: i=1; AFNElJ+to2ZjcP5wNXH/oHgwVDGvvlhkHdCAGBPW5J91YYYpGbnHGyR77GaoRD4OM+WOi8Grw68LfPUqgeNGTbc=@vger.kernel.org X-Gm-Message-State: AOJu0YxAqEZNpYGQD/8oqq0ZGqz1Ko9s0u3/ZZuslmmcUpn5ycxvCk/b foaswTZNcs+HUPedMNuvIkq4EKBpZ7DkOYgMLuKT8RPPNheqVdlMGiPNIa0c5MWiIpM= X-Gm-Gg: Acq92OFo1s/+heycEVggeQL1Sx+DiBpWw0gth6Teu2JVhmiw7OtKZX0D+W+Z3CSH0fT 3z6ZgI6BEk1tIerHEVwrpTPMa8aaWZFCjdcrV453imzh3SS5K8iaOD1DtGcusZczl88LOdM64qS EHACavzH+sbK/Wq27Wks5LwIDu/sFfvKmWnIGd8sVfAvr8Z8I+tvgWCGpQPs4TKAx86kdNhbNSB RdcZzRatRSpUkBeeohlYuf+pc+ffhS6Te7acoVcOnaCQqi7WZPqkWwYJoRnJ6pA5GZaQ1btFuFC o2qzBYkhllJIqx77H8qcDaRyYD+FhTL3ufYI5vyX0g07sTKmH0JTYIDWrL5JQ+LzKba5iKayDXx LalZlfJrqzEq23HNFnc+OLcwa7ksUZ11WWTTlbD8wr89L5Dmj6lXCgtaaT3JOMvXIdI28SDAc4O cGbF6q6Jzal8C4dbQ0YvY2gjfIotH3P07yZWp2lvjVXT1Inbu6z+48USTeXJxZsb6Nz6BSIKLWU WXwE3r3UWoj/MLWtaZDmLE1rQ== X-Received: by 2002:a17:902:db02:b0:2b0:67a7:5c4b with SMTP id d9443c01a7336-2ba79bdcd67mr114567055ad.28.1778230789622; Fri, 08 May 2026 01:59:49 -0700 (PDT) Received: from localhost.localdomain ([111.202.175.43]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2baf1d2709bsm15526795ad.5.2026.05.08.01.59.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 08 May 2026 01:59:49 -0700 (PDT) From: ZhengYuan Huang To: mark@fasheh.com, jlbec@evilplan.org, joseph.qi@linux.alibaba.com Cc: ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org, baijiaju1990@gmail.com, r33s3n6@gmail.com, zzzccc427@gmail.com, ZhengYuan Huang Subject: [PATCH 2/5] ocfs2: validate inline xattr header before checking outside values Date: Fri, 8 May 2026 16:59:11 +0800 Message-ID: <20260508085914.61647-3-gality369@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260508085914.61647-1-gality369@gmail.com> References: <20260508085914.61647-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 corrupt inline xattr header can make ocfs2_has_inline_xattr_value_outside() walk xh_count from an unchecked header while refcount-tree teardown decides whether inline xattrs still point outside the inode body. [CAUSE] ocfs2_has_inline_xattr_value_outside() still computed the inline header directly from di->i_xattr_inline_size and immediately iterated xh_count. That is the same unchecked metadata boundary as the ibody lookup bug. [FIX] Reuse the shared inline-header helper before iterating xh_count. Because this helper returns a boolean-style answer to its caller, treat a corrupt header conservatively as "has outside values" instead of walking it. Signed-off-by: ZhengYuan Huang --- fs/ocfs2/xattr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index 3a5a17cdcf7e..05f6f0a886cf 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c @@ -989,11 +989,12 @@ int ocfs2_has_inline_xattr_value_outside(struct inode *inode, struct ocfs2_dinode *di) { struct ocfs2_xattr_header *xh; + int ret; int i; - xh = (struct ocfs2_xattr_header *) - ((void *)di + inode->i_sb->s_blocksize - - le16_to_cpu(di->i_xattr_inline_size)); + ret = ocfs2_xattr_ibody_lookup_header(inode, di, &xh); + if (ret) + return 1; for (i = 0; i < le16_to_cpu(xh->xh_count); i++) if (!ocfs2_xattr_is_local(&xh->xh_entries[i])) -- 2.43.0