diff options
author | Dylan Yudaken <dylany@fb.com> | 2022-06-13 03:11:57 -0700 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2022-06-13 05:13:33 -0600 |
commit | f9437ac0f851cea2374d53594f52fbbefdd977bd (patch) | |
tree | 6ad0bb8421a4d1e287ad7cf8e57113207bbd251a /fs/io_uring.c | |
parent | c6e9fa5c0ab811f4bec36a96337f4b1bb77d142c (diff) | |
download | linux-stable-f9437ac0f851cea2374d53594f52fbbefdd977bd.tar.gz linux-stable-f9437ac0f851cea2374d53594f52fbbefdd977bd.tar.bz2 linux-stable-f9437ac0f851cea2374d53594f52fbbefdd977bd.zip |
io_uring: limit size of provided buffer ring
The type of head and tail do not allow more than 2^15 entries in a
provided buffer ring, so do not allow this.
At 2^16 while each entry can be indexed, there is no way to
disambiguate full vs empty.
Signed-off-by: Dylan Yudaken <dylany@fb.com>
Link: https://lore.kernel.org/r/20220613101157.3687-4-dylany@fb.com
Reviewed-by: Hao Xu <howeyxu@tencent.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r-- | fs/io_uring.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index 6eea18e8330c..85b116ddfd2a 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -13002,6 +13002,10 @@ static int io_register_pbuf_ring(struct io_ring_ctx *ctx, void __user *arg) if (!is_power_of_2(reg.ring_entries)) return -EINVAL; + /* cannot disambiguate full vs empty due to head/tail size */ + if (reg.ring_entries >= 65536) + return -EINVAL; + if (unlikely(reg.bgid < BGID_ARRAY && !ctx->io_bl)) { int ret = io_init_bl_list(ctx); if (ret) |