]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfs: pin inodes that would otherwise overflow link count
authorDarrick J. Wong <djwong@kernel.org>
Mon, 29 Jul 2024 23:22:40 +0000 (16:22 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 30 Jul 2024 00:01:00 +0000 (17:01 -0700)
commit7bde36b0617bccc2cd97571952941b272a80a479
tree04f1f784dbd38fe399c1d4933891c8f6c941a672
parentc9d6544ce58a377179493f3dd655055060f6ac7a
xfs: pin inodes that would otherwise overflow link count

Source kernel commit: 5f204051d998ec3d7306db0d749bddcbf4c97693

The VFS inc_nlink function does not explicitly check for integer
overflows in the i_nlink field.  Instead, it checks the link count
against s_max_links in the vfs_{link,create,rename} functions.  XFS
sets the maximum link count to 2.1 billion, so integer overflows should
not be a problem.

However.  It's possible that online repair could find that a file has
more than four billion links, particularly if the link count got
corrupted while creating hardlinks to the file.  The di_nlinkv2 field is
not large enough to store a value larger than 2^32, so we ought to
define a magic pin value of ~0U which means that the inode never gets
deleted.  This will prevent a UAF error if the repair finds this
situation and users begin deleting links to the file.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
libxfs/xfs_format.h