io_uring: validate the full range of provided buffers for access
authorBijan Mottahedeh <bijan.mottahedeh@oracle.com>
Fri, 5 Jun 2020 01:01:52 +0000 (18:01 -0700)
committerJens Axboe <axboe@kernel.dk>
Mon, 8 Jun 2020 15:39:13 +0000 (09:39 -0600)
Account for the number of provided buffers when validating the address
range.

Signed-off-by: Bijan Mottahedeh <bijan.mottahedeh@oracle.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c

index 70f0f2f..5431b18 100644 (file)
@@ -3183,7 +3183,7 @@ static int io_provide_buffers_prep(struct io_kiocb *req,
        p->addr = READ_ONCE(sqe->addr);
        p->len = READ_ONCE(sqe->len);
 
-       if (!access_ok(u64_to_user_ptr(p->addr), p->len))
+       if (!access_ok(u64_to_user_ptr(p->addr), (p->len * p->nbufs)))
                return -EFAULT;
 
        p->bgid = READ_ONCE(sqe->buf_group);