]> git.baikalelectronics.ru Git - kernel.git/commit
xfs: reserve quota for target dir expansion when renaming files
authorDarrick J. Wong <djwong@kernel.org>
Wed, 9 Mar 2022 18:10:50 +0000 (10:10 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 14 Mar 2022 17:23:17 +0000 (10:23 -0700)
commit970a23ef804bb748a4fcafc6f45857b786649e63
treeaad2e034f5699eb17f21862fa892ebad42344df1
parent10110c8ec89d17268c4e5a2714f0f87d0e82da97
xfs: reserve quota for target dir expansion when renaming files

XFS does not reserve quota for directory expansion when renaming
children into a directory.  This means that we don't reject the
expansion with EDQUOT when we're at or near a hard limit, which means
that unprivileged userspace can use rename() to exceed quota.

Rename operations don't always expand the target directory, and we allow
a rename to proceed with no space reservation if we don't need to add a
block to the target directory to handle the addition.  Moreover, the
unlink operation on the source directory generally does not expand the
directory (you'd have to free a block and then cause a btree split) and
it's probably of little consequence to leave the corner case that
renaming a file out of a directory can increase its size.

As with link and unlink, there is a further bug in that we do not
trigger the blockgc workers to try to clear space when we're out of
quota.

Because rename is its own special tricky animal, we'll patch xfs_rename
directly to reserve quota to the rename transaction.  We'll leave
cleaning up the rest of xfs_rename for the metadata directory tree
patchset.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
fs/xfs/xfs_inode.c