]> git.hungrycats.org Git - linux/commitdiff
xfs: take hm->lock in xfs_ioc_health_monitor() before insert
authorDeepanshu Kartikey <kartikey406@gmail.com>
Sun, 6 Sep 2026 14:46:29 +0000 (20:16 +0530)
committerCarlos Maiolino <cem@kernel.org>
Thu, 10 Sep 2026 14:43:48 +0000 (16:43 +0200)
__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@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=ccdf3469f5f653bff7ac
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/xfs_healthmon.c

index b57fa033cec4b46565f8b61782ccabe51251abf1..c3749675ef19217473eea2e2862808f862786359 100644 (file)
@@ -1223,7 +1223,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, INSERT_HEAD, running_event);
+       mutex_unlock(&hm->lock);
 
        /*
         * Preallocate the unmount event so that we can't fail to notify the