]> git.baikalelectronics.ru Git - kernel.git/commit
fanotify: fix double free of pending permission events
authorJan Kara <jack@suse.cz>
Wed, 6 Aug 2014 23:03:28 +0000 (16:03 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 7 Aug 2014 01:01:12 +0000 (18:01 -0700)
commit81aecb9109620f16e7a91d14e75c4d031b90a72e
treee639967a7baf1b1c6a0d1b5e0babc8083c7faad4
parentc585fc14f6f71508cda7f4edb0f3c4c76db744c5
fanotify: fix double free of pending permission events

Commit fd56edf1b109 ("fanotify: Fix use after free for permission
events") introduced a double free issue for permission events which are
pending in group's notification queue while group is being destroyed.
These events are freed from fanotify_handle_event() but they are not
removed from groups notification queue and thus they get freed again
from fsnotify_flush_notify().

Fix the problem by removing permission events from notification queue
before freeing them if we skip processing access response.  Also expand
comments in fanotify_release() to explain group shutdown in detail.

Fixes: fd56edf1b10918af8925e6dbdd220105883706ea
Signed-off-by: Jan Kara <jack@suse.cz>
Reported-by: Douglas Leeder <douglas.leeder@sophos.com>
Tested-by: Douglas Leeder <douglas.leeder@sophos.com>
Reported-by: Heinrich Schuchard <xypron.glpk@gmx.de>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/notify/fanotify/fanotify.c
fs/notify/fanotify/fanotify_user.c
fs/notify/notification.c
include/linux/fsnotify_backend.h