All of lore.kernel.org
 help / color / mirror / Atom feed
* [merged] fanotify-fix-event-filtering-with-fan_ondir-set.patch removed from -mm tree
@ 2015-03-16 18:02 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2015-03-16 18:02 UTC (permalink / raw)
  To: suzuki.poulose, LinoSanfilippo, eparis, jack, will.deacon, mm-commits


The patch titled
     Subject: fanotify: fix event filtering with FAN_ONDIR set
has been removed from the -mm tree.  Its filename was
     fanotify-fix-event-filtering-with-fan_ondir-set.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: "Suzuki K. Poulose" <suzuki.poulose@arm.com>
Subject: fanotify: fix event filtering with FAN_ONDIR set

With FAN_ONDIR set, the user can end up getting events, which it hasn't
marked.  This was revealed with fanotify04 testcase failure on
Linux-4.0-rc1, and is a regression from 3.19, revealed with 66ba93c0d7fe6
("fanotify: don't set FAN_ONDIR implicitly on a marks ignored mask").

 # /opt/ltp/testcases/bin/fanotify04
 [ ... ]
fanotify04    7  TPASS  :  event generated properly for type 100000
fanotify04    8  TFAIL  :  fanotify04.c:147: got unexpected event 30
fanotify04    9  TPASS  :  No event as expected

The testcase sets the adds the following marks : FAN_OPEN | FAN_ONDIR for
a fanotify on a dir.  Then does an open(), followed by close() of the
directory and expects to see an event FAN_OPEN(0x20).  However, the
fanotify returns (FAN_OPEN|FAN_CLOSE_NOWRITE(0x10)).  This happens due to
the flaw in the check for event_mask in fanotify_should_send_event() which
does:

	if (event_mask & marks_mask & ~marks_ignored_mask)
		return true;

where, event_mask == (FAN_ONDIR | FAN_CLOSE_NOWRITE),
       marks_mask == (FAN_ONDIR | FAN_OPEN),
       marks_ignored_mask == 0

Fix this by masking the outgoing events to the user, as we already take
care of FAN_ONDIR and FAN_EVENT_ON_CHILD.

Signed-off-by: Suzuki K. Poulose <suzuki.poulose@arm.com>
Tested-by: Lino Sanfilippo <LinoSanfilippo@gmx.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Eric Paris <eparis@redhat.com>
Cc: Will Deacon <will.deacon@arm.com>

Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 fs/notify/fanotify/fanotify.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff -puN fs/notify/fanotify/fanotify.c~fanotify-fix-event-filtering-with-fan_ondir-set fs/notify/fanotify/fanotify.c
--- a/fs/notify/fanotify/fanotify.c~fanotify-fix-event-filtering-with-fan_ondir-set
+++ a/fs/notify/fanotify/fanotify.c
@@ -143,7 +143,8 @@ static bool fanotify_should_send_event(s
 	    !(marks_mask & FS_ISDIR & ~marks_ignored_mask))
 		return false;
 
-	if (event_mask & marks_mask & ~marks_ignored_mask)
+	if (event_mask & FAN_ALL_OUTGOING_EVENTS & marks_mask &
+				 ~marks_ignored_mask)
 		return true;
 
 	return false;
_

Patches currently in -mm which might be from suzuki.poulose@arm.com are

linux-next.patch


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-03-16 18:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-16 18:02 [merged] fanotify-fix-event-filtering-with-fan_ondir-set.patch removed from -mm tree akpm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.