提交 c03336ef 编写于 作者: J Jens Axboe 提交者: Joseph Qi

io_uring: retain sockaddr_storage across send/recvmsg async punt

to #26323588

commit b537916ca5107c3a8714b8ab3099c0ec205aec12 upstream.

Jonas reports that he sometimes sees -97/-22 error returns from
sendmsg, if it gets punted async. This is due to not retaining the
sockaddr_storage between calls. Include that in the state we copy when
going async.

Cc: stable@vger.kernel.org # 5.3+
Reported-by: NJonas Bonn <jonas@norrbonn.se>
Tested-by: NJonas Bonn <jonas@norrbonn.se>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Signed-off-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
Acked-by: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
上级 e9fd2309
...@@ -442,6 +442,7 @@ struct io_async_msghdr { ...@@ -442,6 +442,7 @@ struct io_async_msghdr {
struct iovec *iov; struct iovec *iov;
struct sockaddr __user *uaddr; struct sockaddr __user *uaddr;
struct msghdr msg; struct msghdr msg;
struct sockaddr_storage addr;
}; };
struct io_async_rw { struct io_async_rw {
...@@ -3029,12 +3030,11 @@ static int io_sendmsg(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -3029,12 +3030,11 @@ static int io_sendmsg(struct io_kiocb *req, struct io_kiocb **nxt,
sock = sock_from_file(req->file, &ret); sock = sock_from_file(req->file, &ret);
if (sock) { if (sock) {
struct io_async_ctx io; struct io_async_ctx io;
struct sockaddr_storage addr;
unsigned flags; unsigned flags;
if (req->io) { if (req->io) {
kmsg = &req->io->msg; kmsg = &req->io->msg;
kmsg->msg.msg_name = &addr; kmsg->msg.msg_name = &req->io->msg.addr;
/* if iov is set, it's allocated already */ /* if iov is set, it's allocated already */
if (!kmsg->iov) if (!kmsg->iov)
kmsg->iov = kmsg->fast_iov; kmsg->iov = kmsg->fast_iov;
...@@ -3043,7 +3043,7 @@ static int io_sendmsg(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -3043,7 +3043,7 @@ static int io_sendmsg(struct io_kiocb *req, struct io_kiocb **nxt,
struct io_sr_msg *sr = &req->sr_msg; struct io_sr_msg *sr = &req->sr_msg;
kmsg = &io.msg; kmsg = &io.msg;
kmsg->msg.msg_name = &addr; kmsg->msg.msg_name = &io.msg.addr;
io.msg.iov = io.msg.fast_iov; io.msg.iov = io.msg.fast_iov;
ret = sendmsg_copy_msghdr(&io.msg.msg, sr->msg, ret = sendmsg_copy_msghdr(&io.msg.msg, sr->msg,
...@@ -3182,12 +3182,11 @@ static int io_recvmsg(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -3182,12 +3182,11 @@ static int io_recvmsg(struct io_kiocb *req, struct io_kiocb **nxt,
sock = sock_from_file(req->file, &ret); sock = sock_from_file(req->file, &ret);
if (sock) { if (sock) {
struct io_async_ctx io; struct io_async_ctx io;
struct sockaddr_storage addr;
unsigned flags; unsigned flags;
if (req->io) { if (req->io) {
kmsg = &req->io->msg; kmsg = &req->io->msg;
kmsg->msg.msg_name = &addr; kmsg->msg.msg_name = &req->io->msg.addr;
/* if iov is set, it's allocated already */ /* if iov is set, it's allocated already */
if (!kmsg->iov) if (!kmsg->iov)
kmsg->iov = kmsg->fast_iov; kmsg->iov = kmsg->fast_iov;
...@@ -3196,7 +3195,7 @@ static int io_recvmsg(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -3196,7 +3195,7 @@ static int io_recvmsg(struct io_kiocb *req, struct io_kiocb **nxt,
struct io_sr_msg *sr = &req->sr_msg; struct io_sr_msg *sr = &req->sr_msg;
kmsg = &io.msg; kmsg = &io.msg;
kmsg->msg.msg_name = &addr; kmsg->msg.msg_name = &io.msg.addr;
io.msg.iov = io.msg.fast_iov; io.msg.iov = io.msg.fast_iov;
ret = recvmsg_copy_msghdr(&io.msg.msg, sr->msg, ret = recvmsg_copy_msghdr(&io.msg.msg, sr->msg,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册