[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87aa6ujjf6.fsf@tucsk.pomaz.szeredi.hu>
Date: Thu, 15 Dec 2011 10:03:41 +0100
From: Miklos Szeredi <miklos@...redi.hu>
To: Al Viro <viro@...IV.linux.org.uk>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Eric Paris <eparis@...hat.com>, akpm@...ux-foundation.org,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH resend] audit: fix mark refcounting
Updated patch:
----
From: Miklos Szeredi <mszeredi@...e.cz>
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@...e.cz>
CC: Al Viro <viro@...iv.linux.org.uk>
CC: Eric Paris <eparis@...hat.com>
CC: stable@...r.kernel.org
---
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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists