Oleg Nesterov
138e4ad67a
epoll: fix race between ep_poll_callback(POLLFREE) and ep_free()/ep_remove()
...
The race was introduced by me in commit 971316f050 ("epoll:
ep_unregister_pollwait() can use the freed pwq->whead"). I did not
realize that nothing can protect eventpoll after ep_poll_callback() sets
->whead = NULL, only whead->lock can save us from the race with
ep_free() or ep_remove().
Move ->whead = NULL to the end of ep_poll_callback() and add the
necessary barriers.
TODO: cleanup the ewake/EPOLLEXCLUSIVE logic, it was confusing even
before this patch.
Hopefully this explains use-after-free reported by syzcaller:
BUG: KASAN: use-after-free in debug_spin_lock_before
...
_raw_spin_lock_irqsave+0x4a/0x60 kernel/locking/spinlock.c:159
ep_poll_callback+0x29f/0xff0 fs/eventpoll.c:1148
this is spin_lock(eventpoll->lock),
...
Freed by task 17774:
...
kfree+0xe8/0x2c0 mm/slub.c:3883
ep_free+0x22c/0x2a0 fs/eventpoll.c:865
Fixes: 971316f050 ("epoll: ep_unregister_pollwait() can use the freed pwq->whead")
Reported-by: 范龙飞 <long7573@126.com >
Cc: stable@vger.kernel.org
Signed-off-by: Oleg Nesterov <oleg@redhat.com >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-01 13:07:35 -07:00
..
2017-07-11 06:08:58 -04:00
2017-07-11 06:06:17 -04:00
2017-07-15 12:00:42 -07:00
2017-07-10 11:40:19 -07:00
2017-07-15 12:00:42 -07:00
2017-07-12 16:26:00 -07:00
2017-08-24 17:19:02 +02:00
2017-06-20 12:19:14 +02:00
2017-09-01 00:04:26 +02:00
2017-08-30 14:43:11 -05:00
2017-06-29 17:49:23 -04:00
2017-06-12 13:20:20 +02:00
2017-07-09 09:31:22 -07:00
2017-07-15 12:00:42 -07:00
2017-08-24 13:23:03 -07:00
2017-03-09 18:23:27 -08:00
2017-04-20 12:09:55 -06:00
2017-07-11 06:09:21 -04:00
2017-07-05 18:44:22 -04:00
2017-03-03 11:38:56 -08:00
2017-07-18 11:23:56 +02:00
2017-08-14 08:30:06 -04:00
2017-07-17 19:23:18 -07:00
2017-03-09 17:01:10 -08:00
2017-08-11 11:20:48 -07:00
2017-07-15 12:00:42 -07:00
2017-05-08 17:15:14 -07:00
2017-07-18 18:23:39 +02:00
2017-07-15 12:00:42 -07:00
2017-07-18 12:33:16 +02:00
2017-07-07 19:38:17 -07:00
2017-04-19 11:35:55 -07:00
2017-08-31 17:02:21 -07:00
2017-03-17 10:25:59 +09:00
2017-07-13 15:58:03 -04:00
2017-07-08 10:50:54 -07:00
2017-07-06 16:24:35 -07:00
2017-08-11 13:54:09 -07:00
2017-08-24 18:05:30 -04:00
2017-07-03 13:08:04 -07:00
2017-07-07 20:09:10 -04:00
2017-05-28 10:11:48 -07:00
2017-08-02 17:16:13 -07:00
2017-07-06 03:31:46 -04:00
2017-07-15 12:00:42 -07:00
2017-07-20 11:08:21 +02:00
2017-08-10 15:54:07 -07:00
2017-07-15 12:00:42 -07:00
2017-08-07 16:51:28 +02:00
2017-07-06 03:31:46 -04:00
2017-07-18 11:24:08 +02:00
2017-04-08 17:33:32 +02:00
2017-07-05 18:44:22 -04:00
2017-07-06 03:31:46 -04:00
2017-07-14 22:50:57 +02:00
2017-06-14 11:21:02 +02:00
2017-07-07 18:39:15 -07:00
2017-08-17 12:40:33 -07:00
2017-06-27 12:05:36 -06:00
2017-03-02 20:51:15 -05:00
2017-03-02 08:42:36 +01:00
2017-03-02 08:42:39 +01:00
2017-08-16 20:32:02 +02:00
2017-07-16 09:24:05 -07:00
2017-04-26 23:54:06 -04:00
2017-07-07 19:38:17 -07:00
2017-07-10 16:32:30 -07:00
2017-03-21 06:44:32 +01:00
2017-07-08 10:15:02 -07:00
2017-04-17 12:52:27 -04:00
2017-03-02 08:42:36 +01:00
2017-08-31 16:12:59 -07:00
2017-07-15 12:00:42 -07:00
2017-06-27 12:05:36 -06:00
2017-07-03 21:13:25 -07:00
2017-09-01 13:07:35 -07:00
2017-07-07 20:05:08 -07:00
2017-07-07 13:48:18 -07:00
2017-04-17 12:52:26 -04:00
2017-07-06 07:02:25 -04:00
2017-07-06 16:24:30 -07:00
2017-07-15 12:00:42 -07:00
2017-06-20 12:19:14 +02:00
2017-03-02 08:42:35 +01:00
2017-07-12 16:26:05 -07:00
2017-07-08 10:50:54 -07:00
2017-05-09 09:12:53 -07:00
2017-03-02 08:42:37 +01:00
2017-08-11 16:56:33 -07:00
2017-07-12 16:26:00 -07:00
2017-07-06 07:02:29 -04:00
2017-05-27 06:07:19 -04:00
2017-06-22 11:44:55 -04:00
2017-07-19 08:55:18 -07:00
2017-07-03 21:13:25 -07:00
2017-07-19 08:55:18 -07:00
2017-07-15 12:00:42 -07:00
2017-07-06 03:27:09 -04:00
2017-07-07 19:38:17 -07:00
2017-07-06 03:27:09 -04:00
2017-05-23 08:41:17 -05:00
2017-03-02 08:42:38 +01:00
2017-07-07 21:48:15 -07:00
2017-04-17 12:52:24 -04:00
2017-08-28 16:09:19 -07:00
2017-05-08 17:15:12 -07:00
2017-06-20 12:18:27 +02:00
2017-06-29 17:49:23 -04:00
2017-06-09 16:28:01 -04:00
2017-07-08 10:50:54 -07:00
2017-07-11 06:09:21 -04:00
2017-07-05 18:44:23 -04:00
2017-06-30 04:14:38 -04:00
2017-08-10 15:54:07 -07:00
2017-04-17 12:52:23 -04:00
2017-05-08 17:15:13 -07:00