Skip to content

Commit

Permalink
Merge branch 'audit-fixes' of git://git.kernel.org/pub/scm/linux/kern…
Browse files Browse the repository at this point in the history
…el/git/mszeredi/vfs

Pull audit-tree fixes from Miklos Szeredi:
 "The audit subsystem maintainers (Al and Eric) are not responding to
  repeated resends.  Eric did ack them a while ago, but no response
  since then.  So I'm sending these directly to you."

* 'audit-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs:
  audit: clean up refcounting in audit-tree
  audit: fix refcounting in audit-tree
  audit: don't free_chunk() after fsnotify_add_mark()
  • Loading branch information
torvalds committed Aug 21, 2012
2 parents a6b881a + b3e8692 commit 1456c75
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions kernel/audit_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ static void untag_chunk(struct node *p)
spin_unlock(&hash_lock);
spin_unlock(&entry->lock);
fsnotify_destroy_mark(entry);
fsnotify_put_mark(entry);
goto out;
}

Expand All @@ -259,7 +258,7 @@ static void untag_chunk(struct node *p)

fsnotify_duplicate_mark(&new->mark, entry);
if (fsnotify_add_mark(&new->mark, new->mark.group, new->mark.i.inode, NULL, 1)) {
free_chunk(new);
fsnotify_put_mark(&new->mark);
goto Fallback;
}

Expand Down Expand Up @@ -293,7 +292,7 @@ static void untag_chunk(struct node *p)
spin_unlock(&hash_lock);
spin_unlock(&entry->lock);
fsnotify_destroy_mark(entry);
fsnotify_put_mark(entry);
fsnotify_put_mark(&new->mark); /* drop initial reference */
goto out;

Fallback:
Expand Down Expand Up @@ -322,7 +321,7 @@ static int create_chunk(struct inode *inode, struct audit_tree *tree)

entry = &chunk->mark;
if (fsnotify_add_mark(entry, audit_tree_group, inode, NULL, 0)) {
free_chunk(chunk);
fsnotify_put_mark(entry);
return -ENOSPC;
}

Expand All @@ -347,6 +346,7 @@ static int create_chunk(struct inode *inode, struct audit_tree *tree)
insert_hash(chunk);
spin_unlock(&hash_lock);
spin_unlock(&entry->lock);
fsnotify_put_mark(entry); /* drop initial reference */
return 0;
}

Expand Down Expand Up @@ -396,7 +396,7 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
fsnotify_duplicate_mark(chunk_entry, old_entry);
if (fsnotify_add_mark(chunk_entry, chunk_entry->group, chunk_entry->i.inode, NULL, 1)) {
spin_unlock(&old_entry->lock);
free_chunk(chunk);
fsnotify_put_mark(chunk_entry);
fsnotify_put_mark(old_entry);
return -ENOSPC;
}
Expand Down Expand Up @@ -444,8 +444,8 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
spin_unlock(&chunk_entry->lock);
spin_unlock(&old_entry->lock);
fsnotify_destroy_mark(old_entry);
fsnotify_put_mark(chunk_entry); /* drop initial reference */
fsnotify_put_mark(old_entry); /* pair to fsnotify_find mark_entry */
fsnotify_put_mark(old_entry); /* and kill it */
return 0;
}

Expand Down Expand Up @@ -916,7 +916,12 @@ static void audit_tree_freeing_mark(struct fsnotify_mark *entry, struct fsnotify
struct audit_chunk *chunk = container_of(entry, struct audit_chunk, mark);

evict_chunk(chunk);
fsnotify_put_mark(entry);

/*
* We are guaranteed to have at least one reference to the mark from
* either the inode or the caller of fsnotify_destroy_mark().
*/
BUG_ON(atomic_read(&entry->refcnt) < 1);
}

static bool audit_tree_send_event(struct fsnotify_group *group, struct inode *inode,
Expand Down

0 comments on commit 1456c75

Please sign in to comment.