diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2012-08-15 06:55:22 -0400 |
---|---|---|
committer | Miklos Szeredi <mszeredi@suse.cz> | 2012-08-15 06:55:22 -0400 |
commit | a2140fc0cb0325bb6384e788edd27b9a568714e2 (patch) | |
tree | 2dfe6d8a064d478f1bd376241ecee42af10d6cf1 /kernel | |
parent | 0fe33aae0e94b4097dd433c9399e16e17d638cd8 (diff) |
audit: fix refcounting in audit-tree
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: Miklos Szeredi <mszeredi@suse.cz>
Reported-by: Valentin Avram <aval13@gmail.com>
Reported-by: Peter Moody <pmoody@google.com>
Acked-by: Eric Paris <eparis@redhat.com>
CC: stable@vger.kernel.org
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/audit_tree.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c index 69a58515f43f..2b2ffff9eca2 100644 --- a/kernel/audit_tree.c +++ b/kernel/audit_tree.c | |||
@@ -250,7 +250,6 @@ static void untag_chunk(struct node *p) | |||
250 | spin_unlock(&hash_lock); | 250 | spin_unlock(&hash_lock); |
251 | spin_unlock(&entry->lock); | 251 | spin_unlock(&entry->lock); |
252 | fsnotify_destroy_mark(entry); | 252 | fsnotify_destroy_mark(entry); |
253 | fsnotify_put_mark(entry); | ||
254 | goto out; | 253 | goto out; |
255 | } | 254 | } |
256 | 255 | ||
@@ -293,7 +292,6 @@ static void untag_chunk(struct node *p) | |||
293 | spin_unlock(&hash_lock); | 292 | spin_unlock(&hash_lock); |
294 | spin_unlock(&entry->lock); | 293 | spin_unlock(&entry->lock); |
295 | fsnotify_destroy_mark(entry); | 294 | fsnotify_destroy_mark(entry); |
296 | fsnotify_put_mark(entry); | ||
297 | goto out; | 295 | goto out; |
298 | 296 | ||
299 | Fallback: | 297 | Fallback: |
@@ -332,6 +330,7 @@ static int create_chunk(struct inode *inode, struct audit_tree *tree) | |||
332 | spin_unlock(&hash_lock); | 330 | spin_unlock(&hash_lock); |
333 | chunk->dead = 1; | 331 | chunk->dead = 1; |
334 | spin_unlock(&entry->lock); | 332 | spin_unlock(&entry->lock); |
333 | fsnotify_get_mark(entry); | ||
335 | fsnotify_destroy_mark(entry); | 334 | fsnotify_destroy_mark(entry); |
336 | fsnotify_put_mark(entry); | 335 | fsnotify_put_mark(entry); |
337 | return 0; | 336 | return 0; |
@@ -412,6 +411,7 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree) | |||
412 | spin_unlock(&chunk_entry->lock); | 411 | spin_unlock(&chunk_entry->lock); |
413 | spin_unlock(&old_entry->lock); | 412 | spin_unlock(&old_entry->lock); |
414 | 413 | ||
414 | fsnotify_get_mark(chunk_entry); | ||
415 | fsnotify_destroy_mark(chunk_entry); | 415 | fsnotify_destroy_mark(chunk_entry); |
416 | 416 | ||
417 | fsnotify_put_mark(chunk_entry); | 417 | fsnotify_put_mark(chunk_entry); |
@@ -445,7 +445,6 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree) | |||
445 | spin_unlock(&old_entry->lock); | 445 | spin_unlock(&old_entry->lock); |
446 | fsnotify_destroy_mark(old_entry); | 446 | fsnotify_destroy_mark(old_entry); |
447 | fsnotify_put_mark(old_entry); /* pair to fsnotify_find mark_entry */ | 447 | fsnotify_put_mark(old_entry); /* pair to fsnotify_find mark_entry */ |
448 | fsnotify_put_mark(old_entry); /* and kill it */ | ||
449 | return 0; | 448 | return 0; |
450 | } | 449 | } |
451 | 450 | ||