On Tue, Jun 30, 2020 at 08:42:09AM -0700, Darrick J. Wong wrote: > From: Darrick J. Wong <darrick.wong@xxxxxxxxxx> > > While loading dquot records off disk, make sure that the quota type > flags are the same between the incore dquot and the ondisk dquot. > > Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> > --- > fs/xfs/xfs_dquot.c | 23 ++++++++++++++++++++--- > 1 file changed, 20 insertions(+), 3 deletions(-) > > > diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c > index d5b7f03e93c8..46c8ca83c04d 100644 > --- a/fs/xfs/xfs_dquot.c > +++ b/fs/xfs/xfs_dquot.c > @@ -524,13 +524,27 @@ xfs_dquot_alloc( > } > > /* Copy the in-core quota fields in from the on-disk buffer. */ > -STATIC void > +STATIC int > xfs_dquot_from_disk( > struct xfs_dquot *dqp, > struct xfs_buf *bp) > { > struct xfs_disk_dquot *ddqp = bp->b_addr + dqp->q_bufoffset; > > + /* > + * The only field the verifier didn't check was the quota type flag, so > + * do that here. > + */ > + if ((dqp->dq_flags & XFS_DQ_ALLTYPES) != > + (ddqp->d_flags & XFS_DQ_ALLTYPES) || > + dqp->q_core.d_id != ddqp->d_id) { The comment looks a little weird, as this also checks d_id. Also xfs_dquot_verify verifies d_flags against generally bogus value, it just doesn't check that it matches the type we are looking for. Last but not least dqp->dq_flags only contains the type at this point. So what about something like: /* * Ensure we got the type and ID we were looking for. Everything else * we checked by the verifier. */ if ((ddqp->d_flags & XFS_DQ_ALLTYPES) != dqp->dq_flags || ddqp->d_id != dqp->q_core.d_id)