Skip to content

Commit 31d3ba9

Browse files
isilenceaxboe
authored andcommitted
io_uring: cqe init hardening
io_kiocb::cqe stores the completion info which we'll memcpy to userspace, and we rely on callbacks and other later steps to populate it with right values. We have never had problems with that, but it would still be safer to zero it on allocation. Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/b16a3b64dde678686460d3c3792c3ba6d3d1bc7a.1692916914.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent a0727c7 commit 31d3ba9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

io_uring/io_uring.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ static void io_preinit_req(struct io_kiocb *req, struct io_ring_ctx *ctx)
10561056
req->link = NULL;
10571057
req->async_data = NULL;
10581058
/* not necessary, but safer to zero */
1059-
req->cqe.res = 0;
1059+
memset(&req->cqe, 0, sizeof(req->cqe));
10601060
}
10611061

10621062
static void io_flush_cached_locked_reqs(struct io_ring_ctx *ctx,

0 commit comments

Comments
 (0)