* [PATCH 0/2] xfs: fix zero-link inode link count handling
@ 2026-11-24 11:53 Ran Hongyun
2026-11-24 19:49 ` Dave Chinner
0 siblings, 1 reply; 2+ messages in thread
From: Ran Hongyun @ 2026-11-24 11:53 UTC (permalink / raw)
To: cem, djwong
Cc: linux-xfs, ranhongyun1, chengzhihao1, yangerkun, yi.zhang,
wozizhi
This series fixes two paths that hand a zero-link inode to the VFS link
count helpers.
Patch 1 makes the metadir repair code set the link count directly when
reconnecting an inode that was found on the unlinked list, instead of
calling inc_nlink() on a zero-link inode.
Patch 2 makes xfs_bumplink() reject the abnormal zero link count with
-EFSCORRUPTED. A crafted image can contain a reachable directory with
di_nlink == 0; mkdir() or rename() into it then reaches inc_nlink() and
trips the VFS warning.
Ran Hongyun (2):
xfs: set link count when reconnecting zero-link metadir files
xfs: refuse to bump the link count of zero-link inodes
fs/xfs/libxfs/xfs_dir2.c | 24 ++++++++++++++++++------
fs/xfs/libxfs/xfs_inode_util.c | 14 ++++++++++++--
fs/xfs/libxfs/xfs_inode_util.h | 2 +-
fs/xfs/scrub/metapath.c | 14 ++++++++++++--
fs/xfs/scrub/orphanage.c | 11 ++++++++---
5 files changed, 51 insertions(+), 14 deletions(-)
--
2.52.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 0/2] xfs: fix zero-link inode link count handling
2026-11-24 11:53 [PATCH 0/2] xfs: fix zero-link inode link count handling Ran Hongyun
@ 2026-11-24 19:49 ` Dave Chinner
0 siblings, 0 replies; 2+ messages in thread
From: Dave Chinner @ 2026-11-24 19:49 UTC (permalink / raw)
To: Ran Hongyun
Cc: cem, djwong, linux-xfs, chengzhihao1, yangerkun, yi.zhang,
wozizhi
On Tue, Nov 24, 2026 at 07:53:37PM +0800, Ran Hongyun wrote:
> This series fixes two paths that hand a zero-link inode to the VFS link
> count helpers.
>
> Patch 1 makes the metadir repair code set the link count directly when
> reconnecting an inode that was found on the unlinked list, instead of
> calling inc_nlink() on a zero-link inode.
>
> Patch 2 makes xfs_bumplink() reject the abnormal zero link count with
> -EFSCORRUPTED. A crafted image can contain a reachable directory with
> di_nlink == 0; mkdir() or rename() into it then reaches inc_nlink() and
> trips the VFS warning.
With your changes, it shuts down the filesystem instead of issuing a
warning and allowing things to keep working, yes? i.e. it turns a
warning in a production system into a guaranteed denial of service.
AFAICT, the link count being wrong doesn't immediately result in
anything worse than the link count being wrong. The warning is there
to tell us the link count is wrong, but I'm not convinced that
turning a warning into a shutdown is the right thing to be doing
here.
If we are going to abort modification operations on inodes with
incorrect zero link counts, then the link count needs to be checked
-before- we start modifying anything in the transaction, not deep in
the guts where we cannot sanely back out with an error. i.e.
xfs_bumplink() is the wrong place to be doing these sorts of
corruption checks.
-Dave.
--
Dave Chinner
dgc@kernel.org
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-24 19:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 11:53 [PATCH 0/2] xfs: fix zero-link inode link count handling Ran Hongyun
2026-11-24 19:49 ` Dave Chinner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox