Re: [PATCH] xfs: take hm->lock in xfs_ioc_health_monitor() before insert
From: Darrick J. Wong
Date: Mon Sep 07 2026 - 00:57:43 EST
On Sun, Sep 06, 2026 at 08:16:29PM +0530, Deepanshu Kartikey wrote:
> __xfs_healthmon_insert() asserts that hm->lock is held
> (lockdep_assert_held), but xfs_ioc_health_monitor() called it right
> after allocating hm, before ever taking the lock, triggering a
> lockdep warning.
>
> Take hm->lock around the call.
>
> Fixes: b3a289a2a9397 ("xfs: create event queuing, formatting, and discovery infrastructure")
> Reported-by: syzbot+ccdf3469f5f653bff7ac@xxxxxxxxxxxxxxxxxxxxxxxxx
> Closes: https://syzkaller.appspot.com/bug?extid=ccdf3469f5f653bff7ac
> Signed-off-by: Deepanshu Kartikey <kartikey406@xxxxxxxxx>
Heh, I added a patch just like this one to my own tree.
Reviewed-by: "Darrick J. Wong" <djwong@xxxxxxxxxx>
--D
> ---
> fs/xfs/xfs_healthmon.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/xfs/xfs_healthmon.c b/fs/xfs/xfs_healthmon.c
> index 3ae5f4496ad1..2f762f90d329 100644
> --- a/fs/xfs/xfs_healthmon.c
> +++ b/fs/xfs/xfs_healthmon.c
> @@ -1219,7 +1219,9 @@ xfs_ioc_health_monitor(
> }
> running_event->type = XFS_HEALTHMON_RUNNING;
> running_event->domain = XFS_HEALTHMON_MOUNT;
> + mutex_lock(&hm->lock);
> __xfs_healthmon_insert(hm, running_event);
> + mutex_unlock(&hm->lock);
>
> /*
> * Preallocate the unmount event so that we can't fail to notify the
> --
> 2.34.1
>
>