From d3dc2020f862b6e0185e6136e095da2eb7978b46 Mon Sep 17 00:00:00 2001 From: liuh Date: Mon, 3 Nov 2025 22:51:03 +0800 Subject: [PATCH] xfs_repair: don't leak the rootdir inode when orphanage already exists --- ...-leak-the-rootdir-inode-when-orphana.patch | 44 +++++++++++++++++++ xfsprogs.spec | 6 ++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 0012-xfs_repair-don-t-leak-the-rootdir-inode-when-orphana.patch diff --git a/0012-xfs_repair-don-t-leak-the-rootdir-inode-when-orphana.patch b/0012-xfs_repair-don-t-leak-the-rootdir-inode-when-orphana.patch new file mode 100644 index 0000000..ef3521a --- /dev/null +++ b/0012-xfs_repair-don-t-leak-the-rootdir-inode-when-orphana.patch @@ -0,0 +1,44 @@ +From b67a805cf877525ce74031832a07f6359c04cc9b Mon Sep 17 00:00:00 2001 +From: "Darrick J. Wong" +Date: Mon, 29 Jul 2024 16:22:33 -0700 +Subject: xfs_repair: don't leak the rootdir inode when orphanage already + exists + +If repair calls mk_orphanage and the /lost+found directory already +exists, we need to irele the root directory before exiting the function. + +Fixes: 6c39a3cbda32 ("Don't trash lost+found in phase 4 Merge of master-melb:xfs-cmds:29144a by kenmcd.") +Signed-off-by: Darrick J. Wong +Reviewed-by: Christoph Hellwig +--- + repair/phase6.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/repair/phase6.c b/repair/phase6.c +index 3870c5c..738a2d6 100644 +--- a/repair/phase6.c ++++ b/repair/phase6.c +@@ -906,8 +906,10 @@ mk_orphanage(xfs_mount_t *mp) + xname.len = strlen(ORPHANAGE); + xname.type = XFS_DIR3_FT_DIR; + +- if (libxfs_dir_lookup(NULL, pip, &xname, &ino, NULL) == 0) +- return ino; ++ /* If the lookup of /lost+found succeeds, return the inumber. */ ++ error = -libxfs_dir_lookup(NULL, pip, &xname, &ino, NULL); ++ if (error == 0) ++ goto out_pip; + + /* + * could not be found, create it +@@ -999,6 +1001,7 @@ mk_orphanage(xfs_mount_t *mp) + ORPHANAGE, error); + } + libxfs_irele(ip); ++out_pip: + libxfs_irele(pip); + + return(ino); +-- +2.43.0 + diff --git a/xfsprogs.spec b/xfsprogs.spec index 6b1650a..f4739f8 100644 --- a/xfsprogs.spec +++ b/xfsprogs.spec @@ -1,6 +1,6 @@ Name: xfsprogs Version: 6.6.0 -Release: 12 +Release: 13 Summary: Administration and debugging tools for the XFS file system License: GPL-1.0-or-later AND LGPL-2.1-or-later URL: https://xfs.wiki.kernel.org @@ -30,6 +30,7 @@ Patch8: 0008-xfsprogs-link-with-icu-uc.patch Patch9: 0009-xfs_repair-don-t-crash-in-get_inode_parent.patch Patch10: 0010-misc-fix-reversed-calloc-arguments.patch Patch11: 0011-mkfs-fix-the-issue-of-maxpct-set-to-0-not-taking-eff.patch +Patch12: 0012-xfs_repair-don-t-leak-the-rootdir-inode-when-orphana.patch %description xfsprogs are the userspace utilities that manage XFS filesystems. @@ -102,6 +103,9 @@ rm -rf %{buildroot}%{_datadir}/doc/xfsprogs/ %exclude %{_mandir}/man8/xfs_scrub* %changelog +* Mon Nov 3 2025 liuh - 6.6.0-13 +- xfs_repair: don't leak the rootdir inode when orphanage already exists + * Fri Oct 24 2025 liuh - 6.6.0-12 - sync patch from community mkfs: fix the issue of maxpct set to 0 not taking effect -- Gitee