From f48b6274ca933bf0066271e4e8f1903a25c5bdae Mon Sep 17 00:00:00 2001 From: Bijan Mottahedeh Date: Thu, 4 Jun 2020 18:01:52 -0700 Subject: [PATCH 1541/2944] io_uring: validate the full range of provided buffers for access to #28736503 commit efe68c1ca8f49e8c06afd74b699411bfbb8ba1ff upstream Account for the number of provided buffers when validating the address range. Signed-off-by: Bijan Mottahedeh Signed-off-by: Jens Axboe Signed-off-by: Xiaoguang Wang Acked-by: Joseph Qi --- fs/io_uring.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index c87f05d..d6c1107 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -3174,7 +3174,8 @@ 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(VERIFY_WRITE, u64_to_user_ptr(p->addr), p->len)) + if (!access_ok(VERIFY_WRITE, u64_to_user_ptr(p->addr), + p->len * p->nbufs)) return -EFAULT; p->bgid = READ_ONCE(sqe->buf_group); -- 1.8.3.1