diff --git a/xfsprogs-for-next-xfs_repair-allow-symlinks-with-short-remote-targets.patch b/xfsprogs-for-next-xfs_repair-allow-symlinks-with-short-remote-targets.patch new file mode 100644 index 0000000..656047d --- /dev/null +++ b/xfsprogs-for-next-xfs_repair-allow-symlinks-with-short-remote-targets.patch @@ -0,0 +1,80 @@ +From 5a43a00432ebe9ab8b54155703a9eb9e1a1dd4ec Mon Sep 17 00:00:00 2001 +From: "Darrick J. Wong" +Date: Mon, 29 Jul 2024 16:23:31 -0700 +Subject: [PATCH] xfs_repair: allow symlinks with short remote targets + +Symbolic links can have extended attributes. If the attr fork consumes +enough space in the inode record, a shortform symlink can become a +remote symlink. However, if we delete those extended attributes, the +target is not moved back into the inode core. + +IOWs, we can end up with a symlink inode that looks like this: + +core.magic = 0x494e +core.mode = 0120777 +core.version = 3 +core.format = 2 (extents) +core.nlinkv2 = 1 +core.nextents = 1 +core.size = 297 +core.nblocks = 1 +core.naextents = 0 +core.forkoff = 0 +core.aformat = 2 (extents) +u3.bmx[0] = [startoff,startblock,blockcount,extentflag] +0:[0,12,1,0] + +This is a symbolic link with a 297-byte target stored in a disk block, +which is to say this is a symlink with a remote target. The forkoff is +0, which is to say that there's 512 - 176 == 336 bytes in the inode core +to store the data fork. + +Prior to kernel commit 1eb70f54c445f, the kernel was ok with this +arrangement, but the change to symlink validation in that patch now +produces corruption errors on filesystems written by older kernels that +are not otherwise inconsistent. Those changes were inspired by reports +of illegal memory accesses, which I think were a result of making data +fork access decisions based on symlink di_size and not on di_format. + +Unfortunately, for a very long time xfs_repair has flagged these inodes +as being corrupt, even though the kernel has historically been willing +to read and write symlinks with these properties. Resolve the conflict +by adjusting the xfs_repair corruption tests to allow extents format. +This change matches the kernel patch "xfs: allow symlinks with short +remote targets". + +While we're at it, fix a lurking bad symlink fork access. + +Signed-off-by: Darrick J. Wong +Reviewed-by: Christoph Hellwig +Signed-off-by: Pavel Reichl +--- + repair/dinode.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/repair/dinode.c b/repair/dinode.c +index 168cbf48..e36de9bf 100644 +--- a/repair/dinode.c ++++ b/repair/dinode.c +@@ -1036,7 +1036,8 @@ process_symlink_extlist( + int max_blocks; + + if (be64_to_cpu(dino->di_size) <= XFS_DFORK_DSIZE(dino, mp)) { +- if (dino->di_format == XFS_DINODE_FMT_LOCAL) ++ if (dino->di_format == XFS_DINODE_FMT_LOCAL || ++ dino->di_format == XFS_DINODE_FMT_EXTENTS) + return 0; + do_warn( + _("mismatch between format (%d) and size (%" PRId64 ") in symlink ino %" PRIu64 "\n"), +@@ -1368,7 +1369,7 @@ process_symlink( + * get symlink contents into data area + */ + symlink = &data[0]; +- if (be64_to_cpu(dino->di_size) <= XFS_DFORK_DSIZE(dino, mp)) { ++ if (dino->di_format == XFS_DINODE_FMT_LOCAL) { + /* + * local symlink, just copy the symlink out of the + * inode into the data area +-- +2.46.0 + diff --git a/xfsprogs.spec b/xfsprogs.spec index a597031..7939d1d 100644 --- a/xfsprogs.spec +++ b/xfsprogs.spec @@ -1,7 +1,7 @@ Summary: Utilities for managing the XFS filesystem Name: xfsprogs Version: 6.4.0 -Release: 3%{?dist} +Release: 4%{?dist} License: GPL+ and LGPLv2+ URL: https://xfs.wiki.kernel.org Source0: http://kernel.org/pub/linux/utils/fs/xfs/xfsprogs/%{name}-%{version}.tar.xz @@ -37,6 +37,8 @@ Patch10: xfsprogs-6.5.0-xfs_db.xfs.8-xfs_db-add-helper-for-flist_find_type-for-c Patch11: xfsprogs-6.5.0-xfs_repair.xfs.8-xfs_repair-catch-strtol-errors.patch Patch12: xfsprogs-rhelonly-xfs_db-fix-unitialized-variable-in-check_parents-function.patch Patch13: xfsprogs-6.5.0-xfs.8-xfs-fix-bounds-check-in-xfs_defer_agfl_block.patch +# v6.9.0-270-g5a43a004: This patch is taken from the `for-next` branch. +Patch14: xfsprogs-for-next-xfs_repair-allow-symlinks-with-short-remote-targets.patch %description A set of commands to use the XFS filesystem, including mkfs.xfs. @@ -148,6 +150,10 @@ install -m 0644 %{SOURCE3} %{buildroot}%{mkfsdir} %{_libdir}/*.so %changelog +* Thu Aug 15 2024 Pavel Reichl - 6.4.0-4 +- xfs_repair: allow symlinks with short remote targets +- Related: RHEL-54306 and RHEL-53164 + * Thu Jul 11 2024 Bill O'Donnell - 6.4.0-3 - Fix coverity issue - Related: RHEL-39449