io_uring: check reserved fields for recv/recvmsg
authorJens Axboe <axboe@kernel.dk>
Wed, 27 Apr 2022 01:34:57 +0000 (19:34 -0600)
committerJens Axboe <axboe@kernel.dk>
Wed, 27 Apr 2022 02:48:37 +0000 (20:48 -0600)
We should check unused fields for non-zero and -EINVAL if they are set,
making it consistent with other opcodes.

Fixes: aa1fa28fc73e ("io_uring: add support for recvmsg()")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c

index 136c2fc..92ac50f 100644 (file)
@@ -5420,6 +5420,8 @@ static int io_recvmsg_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);