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 06DDD383A2; Mon, 5 May 2025 09:18:34 +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=1746436715; cv=none; b=Bfra5ohu/4iC13JvHqWHMjzZujo9RlVoamQur0KxFEBEzK3l+SZ//IOPMWFwUbS00sRLZLSc0JX29b0ssAUh5bNBPTZbLCUI9FzgNNQRT9ev0tVcjcYqkUkrbjysLS5eVZiVkx77871Dp5sFXGbSUyyjvqmTeIBMoBsTvb0c/yM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746436715; c=relaxed/simple; bh=ou9mmuGvhfcVkGd+FDNCAlsWZ8BME+SEOYyAvSbl9js=; h=Subject:To:Cc:From:Date:In-Reply-To:Message-ID:MIME-Version: Content-Type; b=L/beX7/WR+a0NcowfOhGaeAWBg+sCSkTOZn6ZTocKMsizEXr1qWUVQhlldWRaf6b0jqGxy3ZyDSY56LVwSOuoCeulBCkgSd66szX5x+8gjWSSBwNtMN+QAT1xLEp/SKsWmNGm2tRf+PvgxAU0yrkBvxXoDLua8aufqMTfXluUbI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=aGZvPIbA; 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="aGZvPIbA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24D81C4CEE4; Mon, 5 May 2025 09:18:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1746436714; bh=ou9mmuGvhfcVkGd+FDNCAlsWZ8BME+SEOYyAvSbl9js=; h=Subject:To:Cc:From:Date:In-Reply-To:From; b=aGZvPIbAY+pCniO9qXuozZ7ENi7hfmsLQdxutco1aup8anwEIGk6peuMVe08a2c17 VmyAH/5fA3NHVe0zOZXS6XzDZsCo33vobJ+7/W99rlHKHGFtFDd/0cIFIz0mB/3koG 6GRVB/j8UfsKzI/X7TaPHICkm1IiEP+7IxbXhPf0= Subject: Patch "xfs: allow unlinked symlinks and dirs with zero size" has been added to the 6.1-stable tree To: catherine.hoang@oracle.com,chandan.babu@oracle.com,chandanbabu@kernel.org,djwong@kernel.org,gregkh@linuxfoundation.org,hch@lst.de,leah.rumancik@gmail.com,xfs-stable@lists.linux.dev Cc: From: Date: Mon, 05 May 2025 11:18:23 +0200 In-Reply-To: <20250430212704.2905795-16-leah.rumancik@gmail.com> Message-ID: <2025050523-unclad-coasting-1f59@gregkh> Precedence: bulk X-Mailing-List: xfs-stable@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit X-stable: commit X-Patchwork-Hint: ignore This is a note to let you know that I've just added the patch titled xfs: allow unlinked symlinks and dirs with zero size to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: xfs-allow-unlinked-symlinks-and-dirs-with-zero-size.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >From stable+bounces-139242-greg=kroah.com@vger.kernel.org Wed Apr 30 23:33:18 2025 From: Leah Rumancik Date: Wed, 30 Apr 2025 14:27:02 -0700 Subject: xfs: allow unlinked symlinks and dirs with zero size To: stable@vger.kernel.org Cc: xfs-stable@lists.linux.dev, chandan.babu@oracle.com, catherine.hoang@oracle.com, djwong@kernel.org, Christoph Hellwig , Chandan Babu R , Leah Rumancik Message-ID: <20250430212704.2905795-16-leah.rumancik@gmail.com> From: "Darrick J. Wong" [ Upstream commit 1ec9307fc066dd8a140d5430f8a7576aa9d78cd3 ] For a very very long time, inode inactivation has set the inode size to zero before unmapping the extents associated with the data fork. Unfortunately, commit 3c6f46eacd876 changed the inode verifier to prohibit zero-length symlinks and directories. If an inode happens to get logged in this state and the system crashes before freeing the inode, log recovery will also fail on the broken inode. Therefore, allow zero-size symlinks and directories as long as the link count is zero; nobody will be able to open these files by handle so there isn't any risk of data exposure. Fixes: 3c6f46eacd876 ("xfs: sanity check directory inode di_size") Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Chandan Babu R Signed-off-by: Leah Rumancik Acked-by: "Darrick J. Wong" Signed-off-by: Greg Kroah-Hartman --- fs/xfs/libxfs/xfs_inode_buf.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) --- a/fs/xfs/libxfs/xfs_inode_buf.c +++ b/fs/xfs/libxfs/xfs_inode_buf.c @@ -370,10 +370,13 @@ xfs_dinode_verify_fork( /* * A directory small enough to fit in the inode must be stored * in local format. The directory sf <-> extents conversion - * code updates the directory size accordingly. + * code updates the directory size accordingly. Directories + * being truncated have zero size and are not subject to this + * check. */ if (S_ISDIR(mode)) { - if (be64_to_cpu(dip->di_size) <= fork_size && + if (dip->di_size && + be64_to_cpu(dip->di_size) <= fork_size && fork_format != XFS_DINODE_FMT_LOCAL) return __this_address; } @@ -511,9 +514,19 @@ xfs_dinode_verify( if (mode && xfs_mode_to_ftype(mode) == XFS_DIR3_FT_UNKNOWN) return __this_address; - /* No zero-length symlinks/dirs. */ - if ((S_ISLNK(mode) || S_ISDIR(mode)) && di_size == 0) - return __this_address; + /* + * No zero-length symlinks/dirs unless they're unlinked and hence being + * inactivated. + */ + if ((S_ISLNK(mode) || S_ISDIR(mode)) && di_size == 0) { + if (dip->di_version > 1) { + if (dip->di_nlink) + return __this_address; + } else { + if (dip->di_onlink) + return __this_address; + } + } fa = xfs_dinode_verify_nrext64(mp, dip); if (fa) Patches currently in stable-queue which might be from leah.rumancik@gmail.com are queue-6.1/xfs-revert-commit-44af6c7e59b12.patch queue-6.1/xfs-make-the-seq-argument-to-xfs_bmapi_convert_delalloc-optional.patch queue-6.1/xfs-check-opcode-and-iovec-count-match-in-xlog_recover_attri_commit_pass2.patch queue-6.1/xfs-allow-symlinks-with-short-remote-targets.patch queue-6.1/xfs-match-lock-mode-in-xfs_buffered_write_iomap_begin.patch queue-6.1/xfs-require-xfs_sb_feat_incompat_log_xattrs-for-attr-log-intent-item-recovery.patch queue-6.1/xfs-allow-unlinked-symlinks-and-dirs-with-zero-size.patch queue-6.1/xfs-restrict-when-we-try-to-align-cow-fork-delalloc-to-cowextsz-hints.patch queue-6.1/xfs-fix-xfs_bmap_add_extent_delay_real-for-partial-conversions.patch queue-6.1/xfs-validate-recovered-name-buffers-when-recovering-xattr-items.patch queue-6.1/xfs-make-xfs_bmapi_convert_delalloc-to-allocate-the-target-offset.patch queue-6.1/xfs-convert-delayed-extents-to-unwritten-when-zeroing-post-eof-blocks.patch queue-6.1/xfs-fix-freeing-speculative-preallocations-for-preallocated-files.patch queue-6.1/xfs-make-sure-sb_fdblocks-is-non-negative.patch queue-6.1/xfs-remove-a-racy-if_bytes-check-in-xfs_reflink_end_cow_extent.patch queue-6.1/xfs-fix-error-returns-from-xfs_bmapi_write.patch