From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B220341B349; Tue, 31 Mar 2026 16:29:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774974547; cv=none; b=gx4T6pf6kqRoH+Y19x1w3Hl752fZ/ya0dHBZP3BWOmpgzcmATNTSs6/wubbsC5m9HDznYvxbqG7PkKUg50jbsTDalH8ioQYOW60fwmusamtNZ2mzNWVzoz9229H1/9JZGacuuyiPtajswJDFe4kDegOYmMorEQFji8bQqWR44A0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774974547; c=relaxed/simple; bh=7fqB2Z5x+EeBbqnurz0PaUzGi2Ytfym0yuSaoClJ6rs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EgxAcXLtfwfm8OnSkL9ywJEXkPHDzLWB0TpbsyVB10+k1BeB0ALE80nnb4TH58aUbGfr6cMwvhdbLDyEl0+x5Ri0oEnkHEPX0jck4QmYAq7MsjWldrgvSa3jktuyE/AIDJJqz4yUlXnbLzrnAnvuAkUsQW3QpiWlk9LeTC3Qpfw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ydg5jkTs; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ydg5jkTs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 489E3C19423; Tue, 31 Mar 2026 16:29:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774974547; bh=7fqB2Z5x+EeBbqnurz0PaUzGi2Ytfym0yuSaoClJ6rs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ydg5jkTsAPK8MxuKQgHswFKJBjrB37bAcnFETKMMtSbmX0TIBXg1mQCRTO1gvBioM 9+4AXBn4dhIgwmBgr8ilO/sS69AQFCdoBx4hK5jt8bCj7tw95PTJfcwVu3MkcfZxj9 gYlY9IFpN9jY+HL9c1+qw/7Da13cSCioZs+kJWSY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Darrick J. Wong" , Long Li , Christoph Hellwig , Carlos Maiolino Subject: [PATCH 6.6 128/175] xfs: fix ri_total validation in xlog_recover_attri_commit_pass2 Date: Tue, 31 Mar 2026 18:21:52 +0200 Message-ID: <20260331161734.487723152@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260331161729.779738837@linuxfoundation.org> References: <20260331161729.779738837@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Long Li commit d72f2084e30966097c8eae762e31986a33c3c0ae upstream. 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 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: stable@vger.kernel.org # v6.9 Fixes: ad206ae50eca ("xfs: check opcode and iovec count match in xlog_recover_attri_commit_pass2") Reviewed-by: Darrick J. Wong Signed-off-by: Long Li Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino Signed-off-by: Greg Kroah-Hartman --- fs/xfs/xfs_attr_item.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -746,8 +746,8 @@ xlog_recover_attri_commit_pass2( switch (op) { case XFS_ATTRI_OP_FLAGS_SET: case XFS_ATTRI_OP_FLAGS_REPLACE: - /* Log item, attr name, attr value */ - if (item->ri_total != 3) { + /* Log item, attr name, optional attr value */ + if (item->ri_total != 2 + !!attri_formatp->alfi_value_len) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, attri_formatp, len); return -EFSCORRUPTED;