io_uring: don't touch ctx in setup after ring fd install
authorJens Axboe <axboe@kernel.dk>
Mon, 28 Oct 2019 15:15:33 +0000 (09:15 -0600)
committerJens Axboe <axboe@kernel.dk>
Mon, 28 Oct 2019 15:15:33 +0000 (09:15 -0600)
commit044c1ab399afbe9f2ebef49a3204ef1509826dc7
tree25b1ccdca5d8d48a99f2370144f797f56754866a
parent7b20238d28da46f394d37d4d51cc420e1ff9414a
io_uring: don't touch ctx in setup after ring fd install

syzkaller reported an issue where it looks like a malicious app can
trigger a use-after-free of reading the ctx ->sq_array and ->rings
value right after having installed the ring fd in the process file
table.

Defer ring fd installation until after we're done reading those
values.

Fixes: 75b28affdd6a ("io_uring: allocate the two rings together")
Reported-by: syzbot+6f03d895a6cd0d06187f@syzkaller.appspotmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c