From: Jens Axboe Date: Wed, 27 Apr 2022 01:34:11 +0000 (-0600) Subject: io_uring: check reserved fields for send/sendmsg X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=79c10cb188155196db99bfb1c51ee67f8c587908;p=linux.git io_uring: check reserved fields for send/sendmsg [ Upstream commit 588faa1ea5eecb351100ee5d187b9be99210f70d ] We should check unused fields for non-zero and -EINVAL if they are set, making it consistent with other opcodes. Fixes: 0fa03c624d8f ("io_uring: add support for sendmsg()") Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- diff --git a/fs/io_uring.c b/fs/io_uring.c index 1bf1ea2cd8b09..48c9a550e48c8 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -4786,6 +4786,8 @@ static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL)) return -EINVAL; + if (unlikely(sqe->addr2 || sqe->file_index)) + return -EINVAL; sr->umsg = u64_to_user_ptr(READ_ONCE(sqe->addr)); sr->len = READ_ONCE(sqe->len);