• M
    audit: fix refcounting in audit-tree · a2140fc0
    Miklos Szeredi 提交于
    Refcounting of fsnotify_mark in audit tree is broken.  E.g:
    
                                  refcount
    create_chunk
      alloc_chunk                 1
      fsnotify_add_mark           2
    
    untag_chunk
      fsnotify_get_mark           3
      fsnotify_destroy_mark
        audit_tree_freeing_mark   2
      fsnotify_put_mark           1
      fsnotify_put_mark           0
      via destroy_list
        fsnotify_mark_destroy    -1
    
    This was reported by various people as triggering Oops when stopping auditd.
    
    We could just remove the put_mark from audit_tree_freeing_mark() but that would
    break freeing via inode destruction.  So this patch simply omits a put_mark
    after calling destroy_mark or adds a get_mark before.
    
    The additional get_mark is necessary where there's no other put_mark after
    fsnotify_destroy_mark() since it assumes that the caller is holding a reference
    (or the inode is keeping the mark pinned, not the case here AFAICS).
    Signed-off-by: NMiklos Szeredi <mszeredi@suse.cz>
    Reported-by: NValentin Avram <aval13@gmail.com>
    Reported-by: NPeter Moody <pmoody@google.com>
    Acked-by: NEric Paris <eparis@redhat.com>
    CC: stable@vger.kernel.org
    a2140fc0
audit_tree.c 21.7 KB