Merge tag 'kbuild-fixes-v6.1-4' of git://git.kernel.org/pub/scm/linux/kernel/git...
[platform/kernel/linux-starfive.git] / io_uring / kbuf.c
index 25cd724..e2c4688 100644 (file)
@@ -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;
 }