io_uring: round-up cq size before comparing with rounded sq size
authorJens Axboe <axboe@kernel.dk>
Wed, 11 Nov 2020 17:38:53 +0000 (10:38 -0700)
committerJens Axboe <axboe@kernel.dk>
Wed, 11 Nov 2020 17:42:41 +0000 (10:42 -0700)
commit88ec3211e46344a7d10cf6cb5045f839f7785f8e
tree8f1ba2a9d3b3411b2484e16f1f736b1924a7cc30
parent9a472ef7a3690ac0b77ebfb04c88fa795de2adea
io_uring: round-up cq size before comparing with rounded sq size

If an application specifies IORING_SETUP_CQSIZE to set the CQ ring size
to a specific size, we ensure that the CQ size is at least that of the
SQ ring size. But in doing so, we compare the already rounded up to power
of two SQ size to the as-of yet unrounded CQ size. This means that if an
application passes in non power of two sizes, we can return -EINVAL when
the final value would've been fine. As an example, an application passing
in 100/100 for sq/cq size should end up with 128 for both. But since we
round the SQ size first, we compare the CQ size of 100 to 128, and return
-EINVAL as that is too small.

Cc: stable@vger.kernel.org
Fixes: 33a107f0a1b8 ("io_uring: allow application controlled CQ ring size")
Reported-by: Dan Melnic <dmm@fb.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c