1. 31 5月, 2012 1 次提交
    • N
      fsnotify: handle subfiles' perm events · a4f9a9a6
      Naohiro Aota 提交于
      Recently I'm working on fanotify and found the following strange
      behaviors.
      
      I wrote a program to set fanotify_mark on "/tmp/block" and FAN_DENY
      all events notified.
      
      fanotify_mask = FAN_ALL_EVENTS | FAN_ALL_PERM_EVENTS | FAN_EVENT_ON_CHILD:
      $ cd /tmp/block; cat foo
      cat: foo: Operation not permitted
      
      Operation on the file is blocked as expected.
      
      But,
      
      fanotify_mask = FAN_ALL_PERM_EVENTS | FAN_EVENT_ON_CHILD:
      $ cd /tmp/block; cat foo
      aaa
      
      It's not blocked anymore.  This is confusing behavior.  Also reading
      commit "fsnotify: call fsnotify_parent in perm events", it seems like
      fsnotify should handle subfiles' perm events as well as the other notify
      events.
      
      With this patch, regardless of FAN_ALL_EVENTS set or not:
      $ cd /tmp/block; cat foo
      cat: foo: Operation not permitted
      
      Operation on the file is now blocked properly.
      
      FS_OPEN_PERM and FS_ACCESS_PERM are not listed on FS_EVENTS_POSS_ON_CHILD.
       Due to fsnotify_inode_watches_children() check, if you only specify only
      these events as fsnotify_mask, you don't get subfiles' perm events
      notified.
      
      This patch add the events to FS_EVENTS_POSS_ON_CHILD to get them notified
      even if only these events are specified to fsnotify_mask.
      Signed-off-by: NNaohiro Aota <naota@elisp.net>
      Cc: Eric Paris <eparis@redhat.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      a4f9a9a6
  2. 27 7月, 2011 1 次提交
  3. 07 1月, 2011 1 次提交
  4. 08 12月, 2010 1 次提交
    • L
      fanotify: on group destroy allow all waiters to bypass permission check · 09e5f14e
      Lino Sanfilippo 提交于
      When fanotify_release() is called, there may still be processes waiting for
      access permission. Currently only processes for which an event has already been
      queued into the groups access list will be woken up.  Processes for which no
      event has been queued will continue to sleep and thus cause a deadlock when
      fsnotify_put_group() is called.
      Furthermore there is a race allowing further processes to be waiting on the
      access wait queue after wake_up (if they arrive before clear_marks_by_group()
      is called).
      This patch corrects this by setting a flag to inform processes that the group
      is about to be destroyed and thus not to wait for access permission.
      
      [additional changelog from eparis]
      Lets think about the 4 relevant code paths from the PoV of the
      'operator' 'listener' 'responder' and 'closer'.  Where operator is the
      process doing an action (like open/read) which could require permission.
      Listener is the task (or in this case thread) slated with reading from
      the fanotify file descriptor.  The 'responder' is the thread responsible
      for responding to access requests.  'Closer' is the thread attempting to
      close the fanotify file descriptor.
      
      The 'operator' is going to end up in:
      fanotify_handle_event()
        get_response_from_access()
          (THIS BLOCKS WAITING ON USERSPACE)
      
      The 'listener' interesting code path
      fanotify_read()
        copy_event_to_user()
          prepare_for_access_response()
            (THIS CREATES AN fanotify_response_event)
      
      The 'responder' code path:
      fanotify_write()
        process_access_response()
          (REMOVE A fanotify_response_event, SET RESPONSE, WAKE UP 'operator')
      
      The 'closer':
      fanotify_release()
        (SUPPOSED TO CLEAN UP THE REST OF THIS MESS)
      
      What we have today is that in the closer we remove all of the
      fanotify_response_events and set a bit so no more response events are
      ever created in prepare_for_access_response().
      
      The bug is that we never wake all of the operators up and tell them to
      move along.  You fix that in fanotify_get_response_from_access().  You
      also fix other operators which haven't gotten there yet.  So I agree
      that's a good fix.
      [/additional changelog from eparis]
      
      [remove additional changes to minimize patch size]
      [move initialization so it was inside CONFIG_FANOTIFY_PERMISSION]
      Signed-off-by: NLino Sanfilippo <LinoSanfilippo@gmx.de>
      Signed-off-by: NEric Paris <eparis@redhat.com>
      09e5f14e
  5. 29 10月, 2010 7 次提交
  6. 23 8月, 2010 1 次提交
    • E
      fanotify: flush outstanding perm requests on group destroy · 2eebf582
      Eric Paris 提交于
      When an fanotify listener is closing it may cause a deadlock between the
      listener and the original task doing an fs operation.  If the original task
      is waiting for a permissions response it will be holding the srcu lock.  The
      listener cannot clean up and exit until after that srcu lock is syncronized.
      Thus deadlock.  The fix introduced here is to stop accepting new permissions
      events when a listener is shutting down and to grant permission for all
      outstanding events.  Thus the original task will eventually release the srcu
      lock and the listener can complete shutdown.
      Reported-by: NAndreas Gruenbacher <agruen@suse.de>
      Cc: Andreas Gruenbacher <agruen@suse.de>
      Signed-off-by: NEric Paris <eparis@redhat.com>
      2eebf582
  7. 13 8月, 2010 1 次提交
  8. 28 7月, 2010 27 次提交