io_uring: fix {SQ,IO}POLL with unsupported opcodes
authorPavel Begunkov <asml.silence@gmail.com>
Wed, 3 Jun 2020 15:03:22 +0000 (18:03 +0300)
committerJens Axboe <axboe@kernel.dk>
Thu, 4 Jun 2020 17:13:53 +0000 (11:13 -0600)
commit3232dd02af65f2d01be641120d2a710176b0c7a7
tree5360d001f9c59a513515f6c390f024a0c803a511
parentfd2206e4e97b5bae422d9f2f9ebbc79bc97e44a5
io_uring: fix {SQ,IO}POLL with unsupported opcodes

IORING_SETUP_IOPOLL is defined only for read/write, other opcodes should
be disallowed, otherwise it'll get an error as below. Also refuse
open/close with SQPOLL, as the polling thread wouldn't know which file
table to use.

RIP: 0010:io_iopoll_getevents+0x111/0x5a0
Call Trace:
 ? _raw_spin_unlock_irqrestore+0x24/0x40
 ? do_send_sig_info+0x64/0x90
 io_iopoll_reap_events.part.0+0x5e/0xa0
 io_ring_ctx_wait_and_kill+0x132/0x1c0
 io_uring_release+0x20/0x30
 __fput+0xcd/0x230
 ____fput+0xe/0x10
 task_work_run+0x67/0xa0
 do_exit+0x353/0xb10
 ? handle_mm_fault+0xd4/0x200
 ? syscall_trace_enter+0x18c/0x2c0
 do_group_exit+0x43/0xa0
 __x64_sys_exit_group+0x18/0x20
 do_syscall_64+0x60/0x1e0
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
[axboe: allow provide/remove buffers and files update]
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c