Re: [PATCH resend] audit: fix mark refcounting
From: Miklos Szeredi
Date: Thu Dec 15 2011 - 04:04:34 EST
Updated patch:
----
From: Miklos Szeredi <mszeredi@xxxxxxx>
Subject: fsnotify: hold reference to mark around destroy
Removing the parent of a watched file results in "kernel BUG at
fs/notify/mark.c:139".
To reproduce
add "-w /tmp/audit/dir/watched_file" to audit.rules
rm -rf /tmp/audit/dir
This is caused by fsnotify_destroy_mark() being called without an
extra reference taken by the caller.
Reported by Francesco Cosoleto here:
https://bugzilla.novell.com/show_bug.cgi?id=689860
Linus noticed that the call in
fs/notify/inotify/inotify_fsnotify.c
has also missing reference to mark.
Signed-off-by: Miklos Szeredi <mszeredi@xxxxxxx>
CC: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
CC: Eric Paris <eparis@xxxxxxxxxx>
CC: stable@xxxxxxxxxxxxxxx
---
fs/notify/inotify/inotify_fsnotify.c | 5 ++++-
kernel/audit_watch.c | 2 ++
2 files changed, 6 insertions(+), 1 deletion(-)
Index: linux.git/kernel/audit_watch.c
===================================================================
--- linux.git.orig/kernel/audit_watch.c 2011-12-14 13:59:47.000000000 +0100
+++ linux.git/kernel/audit_watch.c 2011-12-15 09:57:53.000000000 +0100
@@ -349,7 +349,9 @@ static void audit_remove_parent_watches(
}
mutex_unlock(&audit_filter_mutex);
+ audit_get_parent(parent);
fsnotify_destroy_mark(&parent->mark);
+ audit_put_parent(parent);
}
/* Get path information necessary for adding watches. */
Index: linux.git/fs/notify/inotify/inotify_fsnotify.c
===================================================================
--- linux.git.orig/fs/notify/inotify/inotify_fsnotify.c 2011-09-13 16:08:20.000000000 +0200
+++ linux.git/fs/notify/inotify/inotify_fsnotify.c 2011-12-15 09:59:15.000000000 +0100
@@ -130,8 +130,11 @@ static int inotify_handle_event(struct f
ret = PTR_ERR(added_event);
}
- if (inode_mark->mask & IN_ONESHOT)
+ if (inode_mark->mask & IN_ONESHOT) {
+ fsnotify_get_mark(inode_mark);
fsnotify_destroy_mark(inode_mark);
+ fsnotify_put_mark(inode_mark);
+ }
return ret;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/