]> git.karo-electronics.de Git - karo-tx-linux.git/commit
fanotify: dont merge permission events
authorLino Sanfilippo <LinoSanfilippo@gmx.de>
Fri, 23 Mar 2012 01:42:23 +0000 (02:42 +0100)
committerEric Paris <eparis@redhat.com>
Mon, 26 Mar 2012 17:06:12 +0000 (13:06 -0400)
commit7bd17645e7774d63b0f6d9f341d1d2f94d6dad6e
treee2564305d9b95a66bf2f205b7f2fd4d125abb2ac
parent319470a74a466d540c590db0ae3b872e47162b31
fanotify: dont merge permission events

Boyd Yang reported a problem for the case that multiple threads of the same
thread group are waiting for a reponse for a permission event.
In this case it is possible that some of the threads are never woken up, even
if the response for the event has been received
(see http://marc.info/?l=linux-kernel&m=131822913806350&w=2).

The reason is that we are currently merging permission events if they belong to
the same thread group. But we are not prepared to wake up more than one waiter
for each event. We do

wait_event(group->fanotify_data.access_waitq, event->response ||
atomic_read(&group->fanotify_data.bypass_perm));
and after that
  event->response = 0;

which is the reason that even if we woke up all waiters for the same event
some of them may see event->response being already set 0 again, then go back to
sleep and block forever.

With this patch we avoid that more than one thread is waiting for a response
by not merging permission events for the same thread group any more.

Reported-by: Boyd Yang <boyd.yang@gmail.com>
Signed-off-by: Lino Sanfilippo <LinoSanfilipp@gmx.de>
Signed-off-by: Eric Paris <eparis@redhat.com>
fs/notify/fanotify/fanotify.c