Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp753471img; Thu, 21 Mar 2019 08:14:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqwFwaEdmlWXagqR9XN0N4zyqk0hI0IMWp4IPJBwRdjKBlYysHxRJeN26mLtEZ+oua6D7BHu X-Received: by 2002:a17:902:7c0f:: with SMTP id x15mr4002255pll.98.1553181282564; Thu, 21 Mar 2019 08:14:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553181282; cv=none; d=google.com; s=arc-20160816; b=xseqJs4yI31odXonkTjqWKGxYTRWHEXwUgVreQz4CRWw1TZXttgvNN7xdd7rK3pht2 p9HIm4rUAbGn0ooxSay3R4n34AO4k9+QNr/jdeVOLkIze4K/cqk1Y+tcZT5Y/UEn6TKC F53BeB2OG1vIlVfoeLj20aAgTgISkDoj+1iT5U3slIh+jO0upDKCaZKbh9XadeLdYAkg pR32SpMdsVipvJcZjvfu+x7Wg2D1f8oF4P94yTF27VCmsUibMmEvXiM/ZIu9pjw4TE7D sPqe7jDNjxyaRUefEIpRWHxPzt96pr6YI4Oa7jrqOXnIOPPCv1oc9f3bHNcIBKZRTB09 J5Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=WjfiwNi7fMrC8iK8/xrGN4P/K/+7AIZP2jLu9QO+SzY=; b=di9Y890OAEcO5nD5RgCnVRAdKJ3JBcxCZPWp0JZZKa7Wp2stluXZ06wNxKiI9FfQIz aQeeHLiqIk0HkANPfamHIF+F/ZGuxmMCBbAE1LUgbSnxUqeKziiwL8qKUU9WeCGotBR1 DPM8ErWFZu1aR5I4NO3LcYKZ0mBodUvMVQxSXMyQKW/abjJp3lJIJ+pG7qUvUGZ0oWqj rUFMcGob0ceT5wL83K96IWsknab8owRxdzO8KcuiIJ2BAU9sg+V2794r7NFJ2QruVScw svVRe/YqadCWs+9Qu7nogD2cwoGxvmYWBZ+EcBpLGfrbJCIE3vvsuHGSJ6H3zp+JoqZ6 P4+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y10si4605446plt.287.2019.03.21.08.14.24; Thu, 21 Mar 2019 08:14:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728305AbfCUPMD (ORCPT + 99 others); Thu, 21 Mar 2019 11:12:03 -0400 Received: from mx2.suse.de ([195.135.220.15]:56032 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727857AbfCUPMD (ORCPT ); Thu, 21 Mar 2019 11:12:03 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 68874AEE6; Thu, 21 Mar 2019 15:12:01 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 6A0161E0CE4; Thu, 21 Mar 2019 16:12:00 +0100 (CET) From: Jan Kara To: Cc: Orion Poplawski , Vivek Trivedi , Amir Goldstein , , LKML , "Eric W. Biederman" , Jan Kara Subject: [PATCH] fanotify: Make wait for permission events interruptible Date: Thu, 21 Mar 2019 16:11:42 +0100 Message-Id: <20190321151142.17104-1-jack@suse.cz> X-Mailer: git-send-email 2.16.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Switch waiting for response to fanotify permission events interruptible. This allows e.g. the system to be suspended while there are some fanotify permission events pending (which is reportedly pretty common when for example AV solution is in use). However just making the wait interruptible can result in e.g. open(2) returning -EINTR where previously such error code never happened in practice. To avoid confusion of userspace due to this error code, return -ERESTARTNOINTR instead. Signed-off-by: Jan Kara --- fs/notify/fanotify/fanotify.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) Orion, can you give this patch some testing with your usecase? Also if anybody sees any issue with returning -ERESTARTNOINTR I have missed, please speak up. diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c index 6b9c27548997..eb790853844b 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c @@ -92,10 +92,17 @@ static int fanotify_get_response(struct fsnotify_group *group, pr_debug("%s: group=%p event=%p\n", __func__, group, event); - ret = wait_event_killable(group->fanotify_data.access_waitq, - event->state == FAN_EVENT_ANSWERED); + ret = wait_event_interruptible(group->fanotify_data.access_waitq, + event->state == FAN_EVENT_ANSWERED); /* Signal pending? */ if (ret < 0) { + /* + * Force restarting a syscall so that this is mostly invisible + * for userspace which is not prepared for handling EINTR e.g. + * from open(2). + */ + if (ret == -ERESTARTSYS) + ret = -ERESTARTNOINTR; spin_lock(&group->notification_lock); /* Event reported to userspace and no answer yet? */ if (event->state == FAN_EVENT_REPORTED) { -- 2.16.4