Re: [syzbot] Re: [syzbot] [squashfs?] possible deadlock in fsnotify_destroy_mark
From: syzbot
Date: Fri Sep 27 2024 - 04:38:55 EST
For archival purposes, forwarding an incoming command email to
linux-kernel@xxxxxxxxxxxxxxx.
***
Subject: Re: [syzbot] [squashfs?] possible deadlock in fsnotify_destroy_mark
Author: lizhi.xu@xxxxxxxxxxxxx
Use memalloc_nofs_save/memalloc_nofs_restore to make sure we don't end
up with the fs reclaim dependency.
#syz test
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index c7e451d5bd51..70b77b6186a6 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -643,8 +643,13 @@ static int inotify_update_watch(struct fsnotify_group *group, struct inode *inod
/* try to update and existing watch with the new arg */
ret = inotify_update_existing_watch(group, inode, arg);
/* no mark present, try to add a new one */
- if (ret == -ENOENT)
+ if (ret == -ENOENT) {
+ unsigned int nofs_flag;
+
+ nofs_flag = memalloc_nofs_save();
ret = inotify_new_watch(group, inode, arg);
+ memalloc_nofs_restore(nofs_flag);
+ }
fsnotify_group_unlock(group);
return ret;