From: Konstantin Khlebnikov Date: Tue, 17 Jun 2014 02:58:05 +0000 (+0400) Subject: epoll: fix use-after-free in eventpoll_release_file X-Git-Tag: omap-for-v3.16/fixes-rc4~91 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebe06187bf2aec10d537ce4595e416035367d703;p=pandora-kernel.git epoll: fix use-after-free in eventpoll_release_file This fixes use-after-free of epi->fllink.next inside list loop macro. This loop actually releases elements in the body. The list is rcu-protected but here we cannot hold rcu_read_lock because we need to lock mutex inside. The obvious solution is to use list_for_each_entry_safe(). RCU-ness isn't essential because nobody can change this list under us, it's final fput for this file. The bug was introduced by ae10b2b4eb01 ("epoll: optimize EPOLL_CTL_DEL using rcu") Signed-off-by: Konstantin Khlebnikov Reported-by: Cyrill Gorcunov Cc: Stable # 3.13+ Cc: Sasha Levin Cc: Jason Baron Signed-off-by: Linus Torvalds --- Reading git-diff-tree failed