From patchwork Fri Feb 16 09:44:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Trivedi X-Patchwork-Id: 10224241 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 47E59603EE for ; Fri, 16 Feb 2018 09:45:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 397202942C for ; Fri, 16 Feb 2018 09:45:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D64729439; Fri, 16 Feb 2018 09:45:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 964412942C for ; Fri, 16 Feb 2018 09:45:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932353AbeBPJpa (ORCPT ); Fri, 16 Feb 2018 04:45:30 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:15565 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932346AbeBPJp2 (ORCPT ); Fri, 16 Feb 2018 04:45:28 -0500 Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20180216094526epoutp0480bf3f0870279170d201635ed7d16d04~TxTQYKCDd2361023610epoutp04I for ; Fri, 16 Feb 2018 09:45:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20180216094526epoutp0480bf3f0870279170d201635ed7d16d04~TxTQYKCDd2361023610epoutp04I DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1518774326; bh=8+nuGYV6gttOhAe+P5+r/VmPBAloLXdSL+1RNeQMnuQ=; h=From:To:Cc:Subject:Date:References:From; b=R5ZdfK7aRLn8ZfysAUfVaF1vnwuUXl7hHQVSCU9FwN3oHXtByV3QBrg2AiG/Ea/Bq FQC7A1lZvsNO/xFzLVbo46+Um7bFAlC6YOy0cKXrL5ysdLzwVdYNkULde2DT+l0vbw zENGn84ykX/05nYeht75YWp6BeE8oauf7re4VaHk= Received: from epsmges5p1new.samsung.com (unknown [182.195.40.72]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20180216094526epcas5p2e2722c1b386b010608fb75f63631d4f7~TxTPkBNty1945019450epcas5p27; Fri, 16 Feb 2018 09:45:26 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 38.8C.04386.538A68A5; Fri, 16 Feb 2018 18:45:25 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20180216094525epcas5p1e52ea815ed7dfb7516578384dedcf5ae~TxTPGeeNF1358113581epcas5p16; Fri, 16 Feb 2018 09:45:25 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20180216094525epsmtrp25fc7651a24ee46bb2d5a6808a7c6aaf5~TxTPFHwRH1251212512epsmtrp2B; Fri, 16 Feb 2018 09:45:25 +0000 (GMT) X-AuditID: b6c32a49-00dff70000001122-d0-5a86a83532c5 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 90.6A.03698.538A68A5; Fri, 16 Feb 2018 18:45:25 +0900 (KST) Received: from localhost.localdomain (unknown [107.108.92.210]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20180216094523epsmtip1b34933475d61ea39ba2304b8473ef851~TxTNqR1zu3126431264epsmtip1B; Fri, 16 Feb 2018 09:45:23 +0000 (GMT) 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 , Kunal Shubham Subject: [PATCH] fanotify: allow freeze on suspend when waiting for response from userspace Date: Fri, 16 Feb 2018 15:14:40 +0530 Message-Id: <1518774280-38090-1-git-send-email-t.vivek@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrHKsWRmVeSWpSXmKPExsWy7bCmuq7pirYog/WPzS0urFvNaDF7ejOT xcFlM5kt9uw9yWJxedccNot7b7YyWbzs28jmwO6xc9Zddo++LasYPc4sOMLu8XmTXABLVKpN RmpiSmqRQmpecn5KZl66rZJ3cLxzvKmZgaGuoaWFuZJCXmJuqq2Si0+ArltmDtAFSgpliTml QKGAxOJiJX07m6L80pJUhYz84hJbpWhDQyM9QwNzPSMjIz0T01grI1OgkoTUjO8L9jAWvBaq OHn4P2sD4waBLkZODgkBE4lF8y4zdjFycQgJ7GaU2LX9LxuE84lR4uTdH1CZb4wST++tYYRp mf6lgwkisZdRYs7f50wgCSGBL4wS70FsDg42AUmJO7cVQMIiAskSl65/ZwGxmQXSJH6cmQI2 R1ggVuLjjGOsIDaLgKrEw/872EBsXgFniZsvv7FA7JKTOHlsMivILgmBv6wS+649ZIJIuEic ftjBDmELS7w6vgXKlpL4/G4vG0TDZEaJiZM+sEM46xklll59wAxRZS/x4MZRdpBLmQU0Jdbv 0gcxJQRsJQ70SEMcyifR+/sJE0SYV6KjTQiiUVFi4d4prBBhcYmepUEQpodE66NUiApHifbH EN8KAX34qucM0wRGuVkImxYwMq5ilEwtKM5N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uTFXR3naUe4eJZbijERDLeai4kQASUIsAhcCAAA= X-CMS-MailID: 20180216094525epcas5p1e52ea815ed7dfb7516578384dedcf5ae X-Msg-Generator: CA X-MTR: 20180216094525epcas5p1e52ea815ed7dfb7516578384dedcf5ae CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20180216094525epcas5p1e52ea815ed7dfb7516578384dedcf5ae X-RootMTR: 20180216094525epcas5p1e52ea815ed7dfb7516578384dedcf5ae References: Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Vivek Trivedi 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: [] (__schedule) from [] (schedule+0x4c/0xa4) [] (schedule) from [] (fanotify_handle_event+0x1c8/0x218) [] (fanotify_handle_event) from [] (fsnotify+0x17c/0x38c) [] (fsnotify) from [] (security_file_open+0x88/0x8c) [] (security_file_open) from [] (do_dentry_open+0xc0/0x338) [] (do_dentry_open) from [] (vfs_open+0x54/0x58) [] (vfs_open) from [] (do_last.isra.10+0x45c/0xcf8) [] (do_last.isra.10) from [] (path_openat+0x424/0x600) [] (path_openat) from [] (do_filp_open+0x3c/0x98) [] (do_filp_open) from [] (do_sys_open+0x120/0x1e4) [] (do_sys_open) from [] (SyS_open+0x28/0x2c) [] (SyS_open) from [] (__sys_trace_return+0x0/0x20) Signed-off-by: Kunal Shubham Signed-off-by: Vivek Trivedi --- 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 #include #include +#include #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) {