mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] xfs: scrub: unlock dquot before early return in quota scrub
@ 2026-03-12 12:10 hongao
  2026-03-12 14:31 ` Darrick J. Wong
  2026-03-18 10:12 ` Carlos Maiolino
  0 siblings, 2 replies; 3+ messages in thread
From: hongao @ 2026-03-12 12:10 UTC (permalink / raw)
  To: cem, djwong; +Cc: linux-xfs, linux-kernel, hongao

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>

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


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

* Re: [PATCH] xfs: scrub: unlock dquot before early return in quota scrub
  2026-03-12 12:10 [PATCH] xfs: scrub: unlock dquot before early return in quota scrub hongao
@ 2026-03-12 14:31 ` Darrick J. Wong
  2026-03-18 10:12 ` Carlos Maiolino
  1 sibling, 0 replies; 3+ messages in thread
From: Darrick J. Wong @ 2026-03-12 14:31 UTC (permalink / raw)
  To: hongao; +Cc: cem, linux-xfs, linux-kernel

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
> 
> 

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

* Re: [PATCH] xfs: scrub: unlock dquot before early return in quota scrub
  2026-03-12 12:10 [PATCH] xfs: scrub: unlock dquot before early return in quota scrub hongao
  2026-03-12 14:31 ` Darrick J. Wong
@ 2026-03-18 10:12 ` Carlos Maiolino
  1 sibling, 0 replies; 3+ messages in thread
From: Carlos Maiolino @ 2026-03-18 10:12 UTC (permalink / raw)
  To: djwong, hongao; +Cc: linux-xfs, linux-kernel

On Thu, 12 Mar 2026 20:10:26 +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.
> 
> [...]

Applied to for-next, thanks!

[1/1] xfs: scrub: unlock dquot before early return in quota scrub
      commit: 268378b6ad20569af0d1957992de1c8b16c6e900

Best regards,
-- 
Carlos Maiolino <cem@kernel.org>


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

end of thread, other threads:[~2026-03-18 10:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-12 12:10 [PATCH] xfs: scrub: unlock dquot before early return in quota scrub hongao
2026-03-12 14:31 ` Darrick J. Wong
2026-03-18 10:12 ` Carlos Maiolino

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®