Skip to content

Commit 88ec321

Browse files
committed
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: [email protected] Fixes: 33a107f ("io_uring: allow application controlled CQ ring size") Reported-by: Dan Melnic <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 9a472ef commit 88ec321

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: fs/io_uring.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -9226,14 +9226,14 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p,
92269226
* to a power-of-two, if it isn't already. We do NOT impose
92279227
* any cq vs sq ring sizing.
92289228
*/
9229+
p->cq_entries = roundup_pow_of_two(p->cq_entries);
92299230
if (p->cq_entries < p->sq_entries)
92309231
return -EINVAL;
92319232
if (p->cq_entries > IORING_MAX_CQ_ENTRIES) {
92329233
if (!(p->flags & IORING_SETUP_CLAMP))
92339234
return -EINVAL;
92349235
p->cq_entries = IORING_MAX_CQ_ENTRIES;
92359236
}
9236-
p->cq_entries = roundup_pow_of_two(p->cq_entries);
92379237
} else {
92389238
p->cq_entries = 2 * p->sq_entries;
92399239
}

0 commit comments

Comments
 (0)