Skip to contentSkip to conversation

io_uring: fix ltimeout unprep

PATCH Applied Pavel Begunkov 2 participants 4 messages Oct 20, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 io_uring: fix ltimeout unprep

io_unprep_linked_timeout() is broken, first it needs to return back REQ_F_ARM_LTIMEOUT, so the linked timeout is enqueued and disarmed. But now we refcounted it, and linked timeouts may get not executed at all, leaking a request.

Just kill the unprep optimisation.

Fixes 906c6caaf586 ("io_uring: optimise io_prep_linked_timeout()")

---

v2: rebase

 fs/io_uring.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
fs/io_uring.c +1 -6
index e8b71f14ac8b..d5cc103224f1 100644
@@ -1370,11 +1370,6 @@ static void io_req_track_inflight(struct io_kiocb *req)
 	}
 }
 
-static inline void io_unprep_linked_timeout(struct io_kiocb *req)
-{
-	req->flags &= ~REQ_F_LINK_TIMEOUT;
-}
-
 static struct io_kiocb *__io_prep_linked_timeout(struct io_kiocb *req)
 {
 	if (WARN_ON_ONCE(!req->link))
@@ -6985,7 +6980,7 @@ static void __io_queue_sqe(struct io_kiocb *req)
 		switch (io_arm_poll_handler(req)) {
 		case IO_APOLL_READY:
 			if (linked_timeout)
-				io_unprep_linked_timeout(req);
+				io_queue_linked_timeout(linked_timeout);
 			goto issue_sqe;
 		case IO_APOLL_ABORTED:
 			/*
Signature · 1 line
2.33.1
maintainer Applied
#1 lore raw
Quoted 8 lines · Pavel Begunkov

io_unprep_linked_timeout() is broken, first it needs to return back REQ_F_ARM_LTIMEOUT, so the linked timeout is enqueued and disarmed. But now we refcounted it, and linked timeouts may get not executed at all, leaking a request.

Just kill the unprep optimisation.

[...]

Applied, thanks!

[1/1] io_uring: fix ltimeout unprep

      commit: 195f98fe9a0ec47358f32ef297e9874b0238809d

Best regards,

Signature · 1 line
Jens Axboe
#2 lore raw
Quoted 7 lines · Jens Axboe
Quoted 6 lines · Pavel Begunkov

io_unprep_linked_timeout() is broken, first it needs to return back REQ_F_ARM_LTIMEOUT, so the linked timeout is enqueued and disarmed. But now we refcounted it, and linked timeouts may get not executed at all, leaking a request.

Just kill the unprep optimisation.

Jens, if the patches are not too deep, would also be lovely to add reported-by to this and the other one.

Signature · 1 line
Pavel Begunkov
maintainer
#3 lore raw
Quoted 7 lines · Pavel Begunkov
Quoted 6 lines · Jens Axboe
Quoted 5 lines · Pavel Begunkov

io_unprep_linked_timeout() is broken, first it needs to return back REQ_F_ARM_LTIMEOUT, so the linked timeout is enqueued and disarmed. But now we refcounted it, and linked timeouts may get not executed at all, leaking a request.

Quoted 8 lines
Quoted 1 line
Quoted 1 line

Just kill the unprep optimisation.

Jens, if the patches are not too deep, would also be lovely to add reported-by to this and the other one.

Done

Signature · 1 line
Jens Axboe