Pavel Begunkov 51520426f4 io_uring: handle setup-failed ctx in kill_timeouts
general protection fault, probably for non-canonical address
	0xdffffc0000000018: 0000 [#1] KASAN: null-ptr-deref
	in range [0x00000000000000c0-0x00000000000000c7]
RIP: 0010:io_commit_cqring+0x37f/0xc10 fs/io_uring.c:1318
Call Trace:
 io_kill_timeouts+0x2b5/0x320 fs/io_uring.c:8606
 io_ring_ctx_wait_and_kill+0x1da/0x400 fs/io_uring.c:8629
 io_uring_create fs/io_uring.c:9572 [inline]
 io_uring_setup+0x10da/0x2ae0 fs/io_uring.c:9599
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xae

It can get into wait_and_kill() before setting up ctx->rings, and hence
io_commit_cqring() fails. Mimic poll cancel and do it only when we
completed events, there can't be any requests if it failed before
initialising rings.

Fixes: 80c4cbdb5ee60 ("io_uring: do post-completion chore on t-out cancel")
Reported-by: syzbot+0e905eb8228070c457a0@syzkaller.appspotmail.com
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/660261a48f0e7abf260c8e43c87edab3c16736fa.1617014345.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-03-29 06:48:26 -06:00
..
2021-01-24 14:27:20 +01:00
2021-02-23 13:39:45 -08:00
2021-02-23 13:39:45 -08:00
2021-01-24 14:27:20 +01:00
2021-01-24 14:27:20 +01:00
2021-03-05 12:21:14 -08:00
2021-02-23 13:39:45 -08:00
2021-02-23 13:39:45 -08:00
2021-01-24 14:27:20 +01:00
2021-02-23 13:39:45 -08:00
2021-02-28 11:23:38 -08:00
2021-02-23 13:39:45 -08:00
2021-01-24 14:27:20 +01:00
2021-02-28 11:23:38 -08:00
2021-02-28 11:23:38 -08:00
2021-02-23 13:39:45 -08:00
2021-01-24 14:27:20 +01:00
2021-02-23 13:39:45 -08:00
2021-02-23 13:39:45 -08:00
2021-01-24 14:27:20 +01:00
2021-02-28 11:45:25 -08:00
2021-02-23 13:39:45 -08:00
2021-02-23 13:39:45 -08:00
2021-01-24 14:27:20 +01:00
2021-02-28 11:23:38 -08:00
2021-02-23 13:39:45 -08:00
2021-02-23 13:39:45 -08:00
2021-02-23 13:39:45 -08:00
2021-01-24 14:27:20 +01:00
2021-02-23 13:39:45 -08:00
2021-02-23 13:39:45 -08:00
2021-02-27 08:29:02 -08:00
2021-03-05 17:21:25 -08:00
2021-02-24 13:38:26 -08:00
2021-02-23 13:39:45 -08:00
2021-01-24 14:27:20 +01:00
2021-02-23 13:39:45 -08:00
2021-02-23 13:39:45 -08:00
2021-01-24 14:27:20 +01:00
2020-09-10 14:03:31 -07:00
2021-01-24 14:27:20 +01:00
2021-02-23 13:39:45 -08:00
2021-02-28 11:45:25 -08:00
2021-02-23 13:39:45 -08:00
2021-01-24 14:27:20 +01:00
2021-01-24 14:27:20 +01:00
2021-02-28 11:23:38 -08:00
2021-02-26 09:41:05 -08:00
2021-02-24 13:38:26 -08:00
2021-02-28 11:23:38 -08:00
2021-02-24 13:38:26 -08:00
2021-02-23 13:39:45 -08:00
2021-01-24 14:27:19 +01:00
2021-02-23 13:39:45 -08:00
2021-02-21 10:22:20 -08:00
2021-02-23 13:39:45 -08:00
2021-01-29 10:06:46 +05:30
2021-02-26 15:49:51 -07:00
2021-02-23 13:39:45 -08:00
2021-02-23 13:39:45 -08:00
2021-02-24 13:38:26 -08:00
2021-01-24 14:27:20 +01:00
2021-01-24 14:27:19 +01:00
2021-01-21 14:06:00 -07:00
2021-02-21 11:02:48 -08:00
2021-01-24 14:27:20 +01:00
2021-02-13 17:17:53 +01:00
2021-01-24 14:27:18 +01:00