Skip to content

Commit 0045fb1

Browse files
winnscodejankara
authored andcommitted
fanotify: allow freeze when waiting response for permission events
This is a long-standing issue that uninterruptible sleep in fanotify could make system hibernation fail if the usperspace server gets frozen before the process waiting for the response (as reported e.g. [1][2]). A few years ago, there was an attempt to switch to interruptible sleep while waiting [3], but that would lead to EINTR returns from open(2) and break userspace [4], so it's been changed to only killable [5]. And the core freezer logic had been rewritten [6][7] in v6.1, allowing freezing in uninterrupted sleep, so we can solve this problem now. [1] https://lore.kernel.org/lkml/[email protected]/ [2] https://lore.kernel.org/lkml/[email protected]/ [3] https://lore.kernel.org/linux-fsdevel/[email protected]/ [4] https://lore.kernel.org/linux-fsdevel/[email protected]/ [5] https://lore.kernel.org/linux-fsdevel/[email protected]/ [6] https://lore.kernel.org/lkml/[email protected]/ [7] https://lore.kernel.org/lkml/20230908-avoid-spurious-freezer-wakeups-v4-0-6155aa3dafae@quicinc.com/ Signed-off-by: Winston Wen <[email protected]> Signed-off-by: Jan Kara <[email protected]> Message-Id: <[email protected]>
1 parent 8c2c254 commit 0045fb1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/notify/fanotify/fanotify.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,10 @@ static int fanotify_get_response(struct fsnotify_group *group,
228228

229229
pr_debug("%s: group=%p event=%p\n", __func__, group, event);
230230

231-
ret = wait_event_killable(group->fanotify_data.access_waitq,
232-
event->state == FAN_EVENT_ANSWERED);
231+
ret = wait_event_state(group->fanotify_data.access_waitq,
232+
event->state == FAN_EVENT_ANSWERED,
233+
(TASK_KILLABLE|TASK_FREEZABLE));
234+
233235
/* Signal pending? */
234236
if (ret < 0) {
235237
spin_lock(&group->notification_lock);

0 commit comments

Comments
 (0)