diff options
| author | Pavel Begunkov <asml.silence@gmail.com> | 2023-09-14 16:51:09 +0100 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-09-23 11:11:10 +0200 |
| commit | 6a1d1365fafe1b63e6c52ef72b40b1443a11f78c (patch) | |
| tree | 847e44c8813f4f60e647f3a1ffb622994743ad71 /io_uring | |
| parent | e7dcf8339a0f3290944a301d22063d96c9aa4f70 (diff) | |
| download | linux-6a1d1365fafe1b63e6c52ef72b40b1443a11f78c.tar.gz linux-6a1d1365fafe1b63e6c52ef72b40b1443a11f78c.tar.bz2 linux-6a1d1365fafe1b63e6c52ef72b40b1443a11f78c.zip | |
io_uring/net: fix iter retargeting for selected buf
commit c21a8027ad8a68c340d0d58bf1cc61dcb0bc4d2f upstream.
When using selected buffer feature, io_uring delays data iter setup
until later. If io_setup_async_msg() is called before that it might see
not correctly setup iterator. Pre-init nr_segs and judge from its state
whether we repointing.
Cc: stable@vger.kernel.org
Reported-by: syzbot+a4c6e5ef999b68b26ed1@syzkaller.appspotmail.com
Fixes: 0455d4ccec548 ("io_uring: add POLL_FIRST support for send/sendmsg and recv/recvmsg")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/0000000000002770be06053c7757@google.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'io_uring')
| -rw-r--r-- | io_uring/net.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/io_uring/net.c b/io_uring/net.c index 7245218fdbe2..9fe1aada3ad0 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -170,6 +170,10 @@ static int io_setup_async_msg(struct io_kiocb *req, memcpy(async_msg, kmsg, sizeof(*kmsg)); if (async_msg->msg.msg_name) async_msg->msg.msg_name = &async_msg->addr; + + if ((req->flags & REQ_F_BUFFER_SELECT) && !async_msg->msg.msg_iter.nr_segs) + return -EAGAIN; + /* if were using fast_iov, set it to the new one */ if (!kmsg->free_iov) { size_t fast_idx = kmsg->msg.msg_iter.iov - kmsg->fast_iov; @@ -529,6 +533,7 @@ static int io_recvmsg_copy_hdr(struct io_kiocb *req, struct io_async_msghdr *iomsg) { iomsg->msg.msg_name = &iomsg->addr; + iomsg->msg.msg_iter.nr_segs = 0; #ifdef CONFIG_COMPAT if (req->ctx->compat) |
