提交 50e96989 编写于 作者: P Pavel Begunkov 提交者: Jens Axboe

io_uring: reg buffer overflow checks hardening

We are safe with overflows in io_sqe_buffer_register() because it will
just yield alloc failure, but it's nicer to check explicitly.
Signed-off-by: NPavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/2b0625551be3d97b80a5fd21c8cd79dc1c91f0b5.1616624589.git.asml.silence@gmail.comSigned-off-by: NJens Axboe <axboe@kernel.dk>
上级 548d819d
...@@ -8404,6 +8404,8 @@ static int io_buffers_map_alloc(struct io_ring_ctx *ctx, unsigned int nr_args) ...@@ -8404,6 +8404,8 @@ static int io_buffers_map_alloc(struct io_ring_ctx *ctx, unsigned int nr_args)
static int io_buffer_validate(struct iovec *iov) static int io_buffer_validate(struct iovec *iov)
{ {
unsigned long tmp, acct_len = iov->iov_len + (PAGE_SIZE - 1);
/* /*
* Don't impose further limits on the size and buffer * Don't impose further limits on the size and buffer
* constraints here, we'll -EINVAL later when IO is * constraints here, we'll -EINVAL later when IO is
...@@ -8416,6 +8418,9 @@ static int io_buffer_validate(struct iovec *iov) ...@@ -8416,6 +8418,9 @@ static int io_buffer_validate(struct iovec *iov)
if (iov->iov_len > SZ_1G) if (iov->iov_len > SZ_1G)
return -EFAULT; return -EFAULT;
if (check_add_overflow((unsigned long)iov->iov_base, acct_len, &tmp))
return -EOVERFLOW;
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册