]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
io_uring: check reserved fields for recv/recvmsg
authorJens Axboe <axboe@kernel.dk>
Wed, 27 Apr 2022 01:34:57 +0000 (19:34 -0600)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 22 Jun 2022 12:22:53 +0000 (14:22 +0200)
BugLink: https://bugs.launchpad.net/bugs/1978234
[ Upstream commit 5a1e99b61b0c81388cde0c808b3e4173907df19f ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
fs/io_uring.c

index 48c9a550e48c8452ec174546a1641cc5c9660092..7aad4bde92e9628e8d8c05ef24c5d1ddd8dcccae 100644 (file)
@@ -5009,6 +5009,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);