Patch "xfs: fix incorrect root dquot corruption error when switching group/project quota types" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    xfs: fix incorrect root dquot corruption error when switching group/project quota types

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     xfs-fix-incorrect-root-dquot-corruption-error-when-switching-group-project-quota-types.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From foo@baz Mon Jun  6 07:00:47 PM CEST 2022
From: Amir Goldstein <amir73il@xxxxxxxxx>
Date: Mon,  6 Jun 2022 17:32:51 +0300
Subject: xfs: fix incorrect root dquot corruption error when switching group/project quota types
To: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Cc: Sasha Levin <sashal@xxxxxxxxxx>, Dave Chinner <david@xxxxxxxxxxxxx>, "Darrick J . Wong" <djwong@xxxxxxxxxx>, Christoph Hellwig <hch@xxxxxx>, Brian Foster <bfoster@xxxxxxxxxx>, Christian Brauner <brauner@xxxxxxxxxx>, Luis Chamberlain <mcgrof@xxxxxxxxxx>, Leah Rumancik <leah.rumancik@xxxxxxxxx>, Adam Manzanares <a.manzanares@xxxxxxxxxxx>, linux-xfs@xxxxxxxxxxxxxxx, stable@xxxxxxxxxxxxxxx, Chandan Babu R <chandanrlinux@xxxxxxxxx>
Message-ID: <20220606143255.685988-5-amir73il@xxxxxxxxx>

From: "Darrick J. Wong" <djwong@xxxxxxxxxx>

commit 45068063efb7dd0a8d115c106aa05d9ab0946257 upstream.

While writing up a regression test for broken behavior when a chprojid
request fails, I noticed that we were logging corruption notices about
the root dquot of the group/project quota file at mount time when
testing V4 filesystems.

In commit afeda6000b0c, I was trying to improve ondisk dquot validation
by making sure that when we load an ondisk dquot into memory on behalf
of an incore dquot, the dquot id and type matches.  Unfortunately, I
forgot that V4 filesystems only have two quota files, and can switch
that file between group and project quota types at mount time.  When we
perform that switch, we'll try to load the default quota limits from the
root dquot prior to running quotacheck and log a corruption error when
the types don't match.

This is inconsequential because quotacheck will reset the second quota
file as part of doing the switch, but we shouldn't leave scary messages
in the kernel log.

Fixes: afeda6000b0c ("xfs: validate ondisk/incore dquot flags")
Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx>
Reviewed-by: Brian Foster <bfoster@xxxxxxxxxx>
Reviewed-by: Chandan Babu R <chandanrlinux@xxxxxxxxx>
Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 fs/xfs/xfs_dquot.c |   39 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)

--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -500,6 +500,42 @@ xfs_dquot_alloc(
 	return dqp;
 }
 
+/* Check the ondisk dquot's id and type match what the incore dquot expects. */
+static bool
+xfs_dquot_check_type(
+	struct xfs_dquot	*dqp,
+	struct xfs_disk_dquot	*ddqp)
+{
+	uint8_t			ddqp_type;
+	uint8_t			dqp_type;
+
+	ddqp_type = ddqp->d_type & XFS_DQTYPE_REC_MASK;
+	dqp_type = xfs_dquot_type(dqp);
+
+	if (be32_to_cpu(ddqp->d_id) != dqp->q_id)
+		return false;
+
+	/*
+	 * V5 filesystems always expect an exact type match.  V4 filesystems
+	 * expect an exact match for user dquots and for non-root group and
+	 * project dquots.
+	 */
+	if (xfs_sb_version_hascrc(&dqp->q_mount->m_sb) ||
+	    dqp_type == XFS_DQTYPE_USER || dqp->q_id != 0)
+		return ddqp_type == dqp_type;
+
+	/*
+	 * V4 filesystems support either group or project quotas, but not both
+	 * at the same time.  The non-user quota file can be switched between
+	 * group and project quota uses depending on the mount options, which
+	 * means that we can encounter the other type when we try to load quota
+	 * defaults.  Quotacheck will soon reset the the entire quota file
+	 * (including the root dquot) anyway, but don't log scary corruption
+	 * reports to dmesg.
+	 */
+	return ddqp_type == XFS_DQTYPE_GROUP || ddqp_type == XFS_DQTYPE_PROJ;
+}
+
 /* Copy the in-core quota fields in from the on-disk buffer. */
 STATIC int
 xfs_dquot_from_disk(
@@ -512,8 +548,7 @@ xfs_dquot_from_disk(
 	 * Ensure that we got the type and ID we were looking for.
 	 * Everything else was checked by the dquot buffer verifier.
 	 */
-	if ((ddqp->d_type & XFS_DQTYPE_REC_MASK) != xfs_dquot_type(dqp) ||
-	    be32_to_cpu(ddqp->d_id) != dqp->q_id) {
+	if (!xfs_dquot_check_type(dqp, ddqp)) {
 		xfs_alert_tag(bp->b_mount, XFS_PTAG_VERIFIER_ERROR,
 			  "Metadata corruption detected at %pS, quota %u",
 			  __this_address, dqp->q_id);


Patches currently in stable-queue which might be from amir73il@xxxxxxxxx are

queue-5.10/xfs-restore-shutdown-check-in-mapped-write-fault-path.patch
queue-5.10/xfs-sync-lazy-sb-accounting-on-quiesce-of-read-only-mounts.patch
queue-5.10/xfs-fix-incorrect-root-dquot-corruption-error-when-switching-group-project-quota-types.patch
queue-5.10/xfs-force-log-and-push-ail-to-clear-pinned-inodes-when-aborting-mount.patch
queue-5.10/fsnotify-fix-wrong-lockdep-annotations.patch
queue-5.10/inotify-show-inotify-mask-flags-in-proc-fdinfo.patch
queue-5.10/xfs-consider-shutdown-in-bmapbt-cursor-delete-assert.patch
queue-5.10/xfs-set-inode-size-after-creating-symlink.patch
queue-5.10/xfs-fix-chown-leaking-delalloc-quota-blocks-when-fssetxattr-fails.patch
queue-5.10/xfs-assert-in-xfs_btree_del_cursor-should-take-into-account-error.patch



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux