]> git.baikalelectronics.ru Git - kernel.git/commit
io_uring: fix failure to verify SQ_AFF cpu
authorJens Axboe <axboe@kernel.dk>
Wed, 15 May 2019 02:00:30 +0000 (20:00 -0600)
committerJens Axboe <axboe@kernel.dk>
Wed, 15 May 2019 02:00:30 +0000 (20:00 -0600)
commit7708fe4c6cc937ff19d974ec5b1b3e8a39b82f42
tree6d688ec8617352cb4167a75b431b34bae4efc5e9
parent3814ec7b845023516e8c9599b193a12be57b12a4
io_uring: fix failure to verify SQ_AFF cpu

The test case we have is rightfully failing with the current kernel:

io_uring_setup(1, 0x7ffe2cafebe0), flags: IORING_SETUP_SQPOLL|IORING_SETUP_SQ_AFF, resv: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000, sq_thread_cpu: 4
expected -1, got 3

This is in a vm, and CPU3 is the last valid one, hence asking for 4
should fail the setup with -EINVAL, not succeed. The problem is that
we're using array_index_nospec() with nr_cpu_ids as the index, hence we
wrap and end up using CPU0 instead of CPU4. This makes the setup
succeed where it should be failing.

We don't need to use array_index_nospec() as we're not indexing any
array with this. Instead just compare with nr_cpu_ids directly. This
is fine as we're checking with cpu_online() afterwards.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c