Skip to content

Commit 3a12fab

Browse files
committed
Merge tag 'io_uring-6.4-2023-06-15' of git://git.kernel.dk/linux
Pull io_uring fixes from Jens Axboe: "A fix for sendmsg with CMSG, and the followup fix discussed for avoiding touching task->worker_private after the worker has started exiting" * tag 'io_uring-6.4-2023-06-15' of git://git.kernel.dk/linux: io_uring/io-wq: clear current->worker_private on exit io_uring/net: save msghdr->msg_control for retries
2 parents b4af682 + adeaa3f commit 3a12fab

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

io_uring/io-wq.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,12 @@ static void io_worker_exit(struct io_worker *worker)
220220
list_del_rcu(&worker->all_list);
221221
raw_spin_unlock(&wq->lock);
222222
io_wq_dec_running(worker);
223-
worker->flags = 0;
223+
/*
224+
* this worker is a goner, clear ->worker_private to avoid any
225+
* inc/dec running calls that could happen as part of exit from
226+
* touching 'worker'.
227+
*/
228+
current->worker_private = NULL;
224229

225230
kfree_rcu(worker, rcu);
226231
io_worker_ref_put(wq);

io_uring/net.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct io_sr_msg {
6565
u16 addr_len;
6666
u16 buf_group;
6767
void __user *addr;
68+
void __user *msg_control;
6869
/* used only for send zerocopy */
6970
struct io_kiocb *notif;
7071
};
@@ -195,11 +196,15 @@ static int io_sendmsg_copy_hdr(struct io_kiocb *req,
195196
struct io_async_msghdr *iomsg)
196197
{
197198
struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg);
199+
int ret;
198200

199201
iomsg->msg.msg_name = &iomsg->addr;
200202
iomsg->free_iov = iomsg->fast_iov;
201-
return sendmsg_copy_msghdr(&iomsg->msg, sr->umsg, sr->msg_flags,
203+
ret = sendmsg_copy_msghdr(&iomsg->msg, sr->umsg, sr->msg_flags,
202204
&iomsg->free_iov);
205+
/* save msg_control as sys_sendmsg() overwrites it */
206+
sr->msg_control = iomsg->msg.msg_control;
207+
return ret;
203208
}
204209

205210
int io_send_prep_async(struct io_kiocb *req)
@@ -297,6 +302,7 @@ int io_sendmsg(struct io_kiocb *req, unsigned int issue_flags)
297302

298303
if (req_has_async_data(req)) {
299304
kmsg = req->async_data;
305+
kmsg->msg.msg_control = sr->msg_control;
300306
} else {
301307
ret = io_sendmsg_copy_hdr(req, &iomsg);
302308
if (ret)

0 commit comments

Comments
 (0)