mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: t.vivek@samsung.com
To: jack@suse.cz, amir73il@gmail.com, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: pankaj.m@samsung.com, Vivek Trivedi <t.vivek@samsung.com>,
	Kunal Shubham <k.shubham@samsung.com>
Subject: [PATCH] fanotify: allow freeze on suspend when waiting for response from userspace
Date: Fri, 16 Feb 2018 15:14:40 +0530	[thread overview]
Message-ID: <1518774280-38090-1-git-send-email-t.vivek@samsung.com> (raw)
In-Reply-To: <CGME20180216094525epcas5p1e52ea815ed7dfb7516578384dedcf5ae@epcas5p1.samsung.com>

From: Vivek Trivedi <t.vivek@samsung.com>

If fanotify userspace response server thread is frozen first,
it may fail to send response from userspace to kernel space listener.
In this scenario, fanotify response listener will never get response
from userepace and fail to suspend.

Use freeze-friendly wait API to handle this issue.

Same problem was reported here:
https://bbs.archlinux.org/viewtopic.php?id=232270

Freezing of tasks failed after 20.005 seconds
(1 tasks refusing to freeze, wq_busy=0)

Backtrace:
[<c0582f80>] (__schedule) from [<c05835d0>] (schedule+0x4c/0xa4)
[<c0583584>] (schedule) from [<c01cb648>] (fanotify_handle_event+0x1c8/0x218)
[<c01cb480>] (fanotify_handle_event) from [<c01c8238>] (fsnotify+0x17c/0x38c)
[<c01c80bc>] (fsnotify) from [<c02676dc>] (security_file_open+0x88/0x8c)
[<c0267654>] (security_file_open) from [<c01854b0>] (do_dentry_open+0xc0/0x338)
[<c01853f0>] (do_dentry_open) from [<c0185a38>] (vfs_open+0x54/0x58)
[<c01859e4>] (vfs_open) from [<c0195480>] (do_last.isra.10+0x45c/0xcf8)
[<c0195024>] (do_last.isra.10) from [<c0196140>] (path_openat+0x424/0x600)
[<c0195d1c>] (path_openat) from [<c0197498>] (do_filp_open+0x3c/0x98)
[<c019745c>] (do_filp_open) from [<c0186b44>] (do_sys_open+0x120/0x1e4)
[<c0186a24>] (do_sys_open) from [<c0186c30>] (SyS_open+0x28/0x2c)
[<c0186c08>] (SyS_open) from [<c0010200>] (__sys_trace_return+0x0/0x20)

Signed-off-by: Kunal Shubham <k.shubham@samsung.com>
Signed-off-by: Vivek Trivedi <t.vivek@samsung.com>
---
 fs/notify/fanotify/fanotify.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
index 6702a6a..1d65899 100644
--- a/fs/notify/fanotify/fanotify.c
+++ b/fs/notify/fanotify/fanotify.c
@@ -11,6 +11,7 @@
 #include <linux/types.h>
 #include <linux/wait.h>
 #include <linux/audit.h>
+#include <linux/freezer.h>
 
 #include "fanotify.h"
 
@@ -63,7 +64,9 @@ static int fanotify_get_response(struct fsnotify_group *group,
 
 	pr_debug("%s: group=%p event=%p\n", __func__, group, event);
 
-	wait_event(group->fanotify_data.access_waitq, event->response);
+	while (!event->response)
+		wait_event_freezable(group->fanotify_data.access_waitq,
+				     event->response);
 
 	/* userspace responded, convert to something usable */
 	switch (event->response & ~FAN_AUDIT) {
-- 
1.9.1

       reply	other threads:[~2018-02-16  9:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20180216094525epcas5p1e52ea815ed7dfb7516578384dedcf5ae@epcas5p1.samsung.com>
2018-02-16  9:44 ` t.vivek [this message]
2018-02-16 10:29   ` Jan Kara
     [not found]   ` <CGME20180216094525epcas5p1e52ea815ed7dfb7516578384dedcf5ae@epcms5p1>
2018-02-22  9:44     ` Kunal Shubham
2018-02-22 14:32       ` Jan Kara
2018-12-29 22:04 Orion Poplawski
2018-12-29 22:34 ` Orion Poplawski
2018-12-30  4:00   ` Orion Poplawski
2019-01-08 10:01     ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1518774280-38090-1-git-send-email-t.vivek@samsung.com \
    --to=t.vivek@samsung.com \
    --cc=amir73il@gmail.com \
    --cc=jack@suse.cz \
    --cc=k.shubham@samsung.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pankaj.m@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®