mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: hongao <hongao@uniontech.com>
Cc: cem@kernel.org, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] xfs: scrub: unlock dquot before early return in quota scrub
Date: Thu, 12 Mar 2026 07:31:32 -0700	[thread overview]
Message-ID: <20260312143132.GJ1770774@frogsfrogsfrogs> (raw)
In-Reply-To: <1C42C3A2C8CD80B0+20260312121026.23660-1-hongao@uniontech.com>

On Thu, Mar 12, 2026 at 08:10:26PM +0800, hongao wrote:
> xchk_quota_item can return early after calling xchk_fblock_process_error.
> When that helper returns false, the function returned immediately without
> dropping dq->q_qlock, which can leave the dquot lock held and risk lock
> leaks or deadlocks in later quota operations.
> 
> Fix this by unlocking dq->q_qlock before the early return.
> 
> Signed-off-by: hongao <hongao@uniontech.com>

Yep, that's a bug.

Cc: <stable@vger.kernel.org> # v6.8
Fixes: 7d1f0e167a067e ("xfs: check the ondisk space mapping behind a dquot")
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> diff --git a/fs/xfs/scrub/quota.c b/fs/xfs/scrub/quota.c
> index 1d25bd5b892e..222812fe202c 100644
> --- a/fs/xfs/scrub/quota.c
> +++ b/fs/xfs/scrub/quota.c
> @@ -171,8 +171,10 @@ xchk_quota_item(
>  
>  	error = xchk_quota_item_bmap(sc, dq, offset);
>  	xchk_iunlock(sc, XFS_ILOCK_SHARED);
> -	if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, offset, &error))
> +	if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, offset, &error)) {
> +		mutex_unlock(&dq->q_qlock);
>  		return error;
> +	}
>  
>  	/*
>  	 * Warn if the hard limits are larger than the fs.
> -- 
> 2.51.0
> 
> 

  reply	other threads:[~2026-03-12 14:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-12 12:10 hongao
2026-03-12 14:31 ` Darrick J. Wong [this message]
2026-03-18 10:12 ` Carlos Maiolino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260312143132.GJ1770774@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=cem@kernel.org \
    --cc=hongao@uniontech.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®