Received: from canpmsgout09.his.huawei.com (canpmsgout09.his.huawei.com [113.46.200.224]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB3F12AD00 for ; Thu, 19 Mar 2026 01:17:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.224 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773883030; cv=none; b=qMOTTiywGpe+XIwT5GY/mylF42V42ocBDDlsjsh0t49YSuWVeludBrEBfzMcSsW6JTBjob0ovcN0gKqeZHvyKWIbxgI90K2fKDMqaX3XfxHtWZJLXeWRE9UAOXMtbRNv6nJsQ09iTj57TbrT/FIcd6kYEkitrl0JCjAdfZ5akfs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773883030; c=relaxed/simple; bh=3z1nyr1VFJdcoh/x/iOUmxFGhTZTCiwceP/OsrhEpCU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PzxDIuFKJ7NItIkITMIjWl6ZCEDbyVK/ZUTmKoMNfamNL0zvujKFIFYAXhNOoQkEozpF2HEiXnaL2CO/mNXfTQxQa726QjtYDC5/RL3x1BLiQ5pcy3JRSpTNYS8x/G8du0qTslsCqF+lLQKoKrS6yZ4u/gXQUjx0PX2g822lHcw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=h-partners.com; dkim=pass (1024-bit key) header.d=h-partners.com header.i=@h-partners.com header.b=Ja0kUnzd; arc=none smtp.client-ip=113.46.200.224 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=h-partners.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=h-partners.com header.i=@h-partners.com header.b="Ja0kUnzd" dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=Hvkt5bUSR6rN8wSrN/AHPFmIFGiO9ObxYd3xOdElaRE=; b=Ja0kUnzdbEGiNTULT0/WUB5UO+Jmb4M5j5dUaxHKhEQHHVRFCM2ksNd4jreXOTh2W8LJsc+hJ Q6rOiauWb52w1N2W6StmBfjlc9508jofGZsadWr/ZT2YPC7kiV1KETlAIogFdqrM0MXlwpqNdRr uWoDcsnSpahLD6xuVJDKpK4= Received: from mail.maildlp.com (unknown [172.19.162.92]) by canpmsgout09.his.huawei.com (SkyGuard) with ESMTPS id 4fbnjJ6cJxz1cySN; Thu, 19 Mar 2026 09:12:04 +0800 (CST) Received: from dggemv705-chm.china.huawei.com (unknown [10.3.19.32]) by mail.maildlp.com (Postfix) with ESMTPS id AB2C240562; Thu, 19 Mar 2026 09:17:04 +0800 (CST) Received: from kwepemn100013.china.huawei.com (7.202.194.116) by dggemv705-chm.china.huawei.com (10.3.19.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 19 Mar 2026 09:17:04 +0800 Received: from huawei.com (10.50.159.234) by kwepemn100013.china.huawei.com (7.202.194.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.36; Thu, 19 Mar 2026 09:17:03 +0800 From: Long Li To: , CC: , , , , , , Subject: [PATCH v2 2/3] xfs: fix ri_total validation in xlog_recover_attri_commit_pass2 Date: Thu, 19 Mar 2026 09:06:17 +0800 Message-ID: <20260319010618.722448-3-leo.lilong@huawei.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20260319010618.722448-1-leo.lilong@huawei.com> References: <20260319010618.722448-1-leo.lilong@huawei.com> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To kwepemn100013.china.huawei.com (7.202.194.116) The ri_total checks for SET/REPLACE operations are hardcoded to 3, but xfs_attri_item_size() only emits a value iovec when value_len > 0, so ri_total is 2 when value_len == 0. For PPTR_SET/PPTR_REMOVE/PPTR_REPLACE, value_len is validated by xfs_attri_validate() to be exactly sizeof(struct xfs_parent_rec) and is never zero, so their hardcoded checks remain correct. This problem may cause log recovery failures. The following script can be used to reproduce the problem: #!/bin/bash mkfs.xfs -f /dev/sda mount /dev/sda /mnt/test/ touch /mnt/test/file for i in {1..200}; do attr -s "user.attr_$i" -V "value_$i" /mnt/test/file > /dev/null done echo 1 > /sys/fs/xfs/debug/larp mount /dev/sda /mnt/test/ echo 1 > /sys/fs/xfs/sda/errortag/larp attr -s "user.zero" -V "" /mnt/test/file echo 0 > /sys/fs/xfs/sda/errortag/larp umount /mnt/test mount /dev/sda /mnt/test/ # mount failed Fix this by deriving the expected count dynamically as "2 + !!value_len" for SET/REPLACE operations. Cc: # v6.9 Fixes: ad206ae50eca ("xfs: check opcode and iovec count match in xlog_recover_attri_commit_pass2") Signed-off-by: Long Li --- fs/xfs/xfs_attr_item.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 8ebdd0926b89..19eaf6b8cd43 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -1049,7 +1049,7 @@ xlog_recover_attri_commit_pass2( case XFS_ATTRI_OP_FLAGS_SET: case XFS_ATTRI_OP_FLAGS_REPLACE: /* Log item, attr name, attr value */ - if (item->ri_total != 3) { + if (item->ri_total != 2 + !!attri_formatp->alfi_value_len) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, attri_formatp, len); return -EFSCORRUPTED; -- 2.39.2