diff --git a/io_uring/kbuf.c b/io_uring/kbuf.c index 25cd724ade184ac452463d18e134d7e3ae469503..e2c46889d5fab614dbeb6b26a8a696d778709b8d 100644 --- a/io_uring/kbuf.c +++ b/io_uring/kbuf.c @@ -346,6 +346,8 @@ int io_provide_buffers_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe tmp = READ_ONCE(sqe->off); if (tmp > USHRT_MAX) return -E2BIG; + if (tmp + p->nbufs >= USHRT_MAX) + return -EINVAL; p->bid = tmp; return 0; }