* [PATCH mmotm/next] fanotify: fix corruption preventing startup
@ 2014-01-12 6:54 Hugh Dickins
2014-01-13 6:04 ` Jan Kara
0 siblings, 1 reply; 2+ messages in thread
From: Hugh Dickins @ 2014-01-12 6:54 UTC (permalink / raw)
To: Jan Kara; +Cc: Andrew Morton, linux-kernel
Two of my machines couldn't boot mmotm with fanotify enabled:
0x40000020 was being or'ed into a group's notification_waitq next
pointer, with sad results. It comes from an over-simplification in
fanotify_merge(): test_event isn't NULL when the loop finds no merge.
Signed-off-by: Hugh Dickins <hughd@google.com>
---
Fixes fsnotify-do-not-share-events-between-notification-groups.patch
fs/notify/fanotify/fanotify.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
--- mmotm/fs/notify/fanotify/fanotify.c 2014-01-10 18:25:01.700448941 -0800
+++ linux/fs/notify/fanotify/fanotify.c 2014-01-11 22:15:31.580961010 -0800
@@ -37,16 +37,19 @@ static bool should_merge(struct fsnotify
static struct fsnotify_event *fanotify_merge(struct list_head *list,
struct fsnotify_event *event)
{
- struct fsnotify_event *test_event = NULL;
+ struct fsnotify_event *test_event;
+ bool do_merge = false;
pr_debug("%s: list=%p event=%p\n", __func__, list, event);
list_for_each_entry_reverse(test_event, list, list) {
- if (should_merge(test_event, event))
+ if (should_merge(test_event, event)) {
+ do_merge = true;
break;
+ }
}
- if (!test_event)
+ if (!do_merge)
return NULL;
test_event->mask |= event->mask;
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH mmotm/next] fanotify: fix corruption preventing startup
2014-01-12 6:54 [PATCH mmotm/next] fanotify: fix corruption preventing startup Hugh Dickins
@ 2014-01-13 6:04 ` Jan Kara
0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2014-01-13 6:04 UTC (permalink / raw)
To: Hugh Dickins; +Cc: Jan Kara, Andrew Morton, linux-kernel
On Sat 11-01-14 22:54:15, Hugh Dickins wrote:
> Two of my machines couldn't boot mmotm with fanotify enabled:
> 0x40000020 was being or'ed into a group's notification_waitq next
> pointer, with sad results. It comes from an over-simplification in
> fanotify_merge(): test_event isn't NULL when the loop finds no merge.
That's a really dumb bug. Thanks for the fix! It looks good, you can add:
Reviewed-by: Jan Kara <jack@suse.cz>
I was wondering why I didn't see this problem during my testing. I was
always running my tests with various debug options enabled (in a hope to
catch more problems ;), in particular with spinlock debugging enabled which
shifted the waitqueue pointers further and the corruption landed in
spinlock debugging fields and never got noticed... Ew :-|
Honza
>
> Signed-off-by: Hugh Dickins <hughd@google.com>
> ---
> Fixes fsnotify-do-not-share-events-between-notification-groups.patch
>
> fs/notify/fanotify/fanotify.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> --- mmotm/fs/notify/fanotify/fanotify.c 2014-01-10 18:25:01.700448941 -0800
> +++ linux/fs/notify/fanotify/fanotify.c 2014-01-11 22:15:31.580961010 -0800
> @@ -37,16 +37,19 @@ static bool should_merge(struct fsnotify
> static struct fsnotify_event *fanotify_merge(struct list_head *list,
> struct fsnotify_event *event)
> {
> - struct fsnotify_event *test_event = NULL;
> + struct fsnotify_event *test_event;
> + bool do_merge = false;
>
> pr_debug("%s: list=%p event=%p\n", __func__, list, event);
>
> list_for_each_entry_reverse(test_event, list, list) {
> - if (should_merge(test_event, event))
> + if (should_merge(test_event, event)) {
> + do_merge = true;
> break;
> + }
> }
>
> - if (!test_event)
> + if (!do_merge)
> return NULL;
>
> test_event->mask |= event->mask;
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-01-13 6:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-12 6:54 [PATCH mmotm/next] fanotify: fix corruption preventing startup Hugh Dickins
2014-01-13 6:04 ` Jan Kara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®