From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lino Sanfilippo Subject: Re: [malware-list] A few concerns about fanotify implementation. Date: Mon, 6 Jun 2011 12:27:54 +0200 Message-ID: <20110606102754.GA25313@lsanfilippo.unix.rd.tt.avira.com> References: <1288095195.29745.4010.camel@novikov-v> <201010261358.46974.tvrtko.ursulin@sophos.com> <1288169699.7715.103.camel@novikov-v> <1288195134.2655.202.camel@localhost.localdomain> <4DE8ACAD.2080003@kaspersky.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Eric Paris , Tvrtko Ursulin , "malware-list@dmesg.printk.net" , "linux-fsdevel@vger.kernel.org" To: Vasily Novikov Return-path: Received: from mailout-de.gmx.net ([213.165.64.23]:53118 "HELO mailout-de.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1755234Ab1FFK3d (ORCPT ); Mon, 6 Jun 2011 06:29:33 -0400 Content-Disposition: inline In-Reply-To: <4DE8ACAD.2080003@kaspersky.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Fri, Jun 03, 2011 at 01:43:09PM +0400, Vasily Novikov wrote: > 3. The fanotify file descriptor is always ready to be written to it. But This is not correct. The fanotify file is only writeable if there is at least one event on the access list (meaning at least one file access event has been read but not already been confirmed by userspace). Otherwise you will get -ENOENT. The applied patch should handle this correctly. Lino Signed-off-by: Lino Sanfilippo --- fs/notify/fanotify/fanotify_user.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 9fde1c0..f39bcc4 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -304,10 +304,15 @@ static unsigned int fanotify_poll(struct file *file, poll_table *wait) int ret = 0; poll_wait(file, &group->notification_waitq, wait); + poll_wait(file, &group->fanotify_data.access_waitq, wait); mutex_lock(&group->notification_mutex); if (!fsnotify_notify_queue_is_empty(group)) - ret = POLLIN | POLLRDNORM; + ret |= POLLIN | POLLRDNORM; mutex_unlock(&group->notification_mutex); + mutex_lock(&group->fanotify_data.access_mutex); + if (!list_empty(&group->fanotify_data.access_list)) + ret |= POLLOUT | POLLWRNORM; + mutex_unlock(&group->fanotify_data.access_mutex); return ret; } -- 1.5.6.5