Skip to content

Commit d5e16d8

Browse files
isilenceaxboe
authored andcommitted
io_uring: fix ->work corruption with poll_add
req->work might be already initialised by the time it gets into __io_arm_poll_handler(), which will corrupt it by using fields that are in an union with req->work. Luckily, the only side effect is missing put_creds(). Clean req->work before going there. Suggested-by: Jens Axboe <[email protected]> Signed-off-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 3e863ea commit d5e16d8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fs/io_uring.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4658,6 +4658,10 @@ static int io_poll_add(struct io_kiocb *req)
46584658
struct io_poll_table ipt;
46594659
__poll_t mask;
46604660

4661+
/* ->work is in union with hash_node and others */
4662+
io_req_work_drop_env(req);
4663+
req->flags &= ~REQ_F_WORK_INITIALIZED;
4664+
46614665
INIT_HLIST_NODE(&req->hash_node);
46624666
INIT_LIST_HEAD(&req->list);
46634667
ipt.pt._qproc = io_poll_queue_proc;

0 commit comments

Comments
 (0)