All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: reserve quota for directory expansion when hardlinking files
@ 2022-03-01  2:51 Darrick J. Wong
  2022-03-01  4:59 ` [PATCH] generic: test that linking into a directory fails with EDQUOT Darrick J. Wong
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Darrick J. Wong @ 2022-03-01  2:51 UTC (permalink / raw)
  To: xfs

From: Darrick J. Wong <djwong@kernel.org>

The XFS implementation of the linkat call does not reserve quota for the
potential directory expansion.  This means that we don't reject the
expansion with EDQUOT when we're at or near a hard limit, which means
that one can use linkat() to exceed quota.  Fix this by adding a quota
reservation.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 fs/xfs/xfs_inode.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 04bf467b1090..6e556c9069e8 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1249,6 +1249,10 @@ xfs_link(
 	xfs_trans_ijoin(tp, sip, XFS_ILOCK_EXCL);
 	xfs_trans_ijoin(tp, tdp, XFS_ILOCK_EXCL);
 
+	error = xfs_trans_reserve_quota_nblks(tp, tdp, resblks, 0, false);
+	if (error)
+		goto error_return;
+
 	error = xfs_iext_count_may_overflow(tdp, XFS_DATA_FORK,
 			XFS_IEXT_DIR_MANIP_CNT(mp));
 	if (error)

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-03-09 16:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-01  2:51 [PATCH] xfs: reserve quota for directory expansion when hardlinking files Darrick J. Wong
2022-03-01  4:59 ` [PATCH] generic: test that linking into a directory fails with EDQUOT Darrick J. Wong
2022-03-08 17:25 ` [PATCH] xfs: reserve quota for directory expansion when hardlinking files Darrick J. Wong
2022-03-08 22:18 ` Dave Chinner
2022-03-08 23:17   ` Darrick J. Wong
2022-03-09  1:12     ` Dave Chinner
2022-03-09 16:44       ` Darrick J. Wong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.