Skip to contentSkip to conversation

io_uring: fix submission-failure handling for uring-cmd

PATCH Applied Kanchan Joshi 2 participants 4 messages Aug 23, 2022 1 message not in the archive io_uring

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20220823152018epcas5p3141ae99b73ba495f1501723d7834ee32@epcas5p3.samsung.com

#1 lore raw

PATCH 1/1 io_uring: fix submission-failure handling for uring-cmd

If ->uring_cmd returned an error value different from -EAGAIN or -EIOCBQUEUED, it gets overridden with IOU_OK. This invites trouble as caller (io_uring core code) handles IOU_OK differently than other error codes.
Fix this by returning the actual error code.

---
 io_uring/uring_cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
io_uring/uring_cmd.c +1 -1
index b0e7feeed365..6f99dbd5d550 100644
@@ -119,7 +119,7 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags)
 		if (ret < 0)
 			req_set_fail(req);
 		io_req_set_res(req, ret, 0);
-		return IOU_OK;
+		return ret;
 	}
 
 	return IOU_ISSUE_SKIP_COMPLETE;
Signature · 1 line
2.25.1
maintainer Applied
#2 lore raw
Quoted 5 lines · Kanchan Joshi

If ->uring_cmd returned an error value different from -EAGAIN or -EIOCBQUEUED, it gets overridden with IOU_OK. This invites trouble as caller (io_uring core code) handles IOU_OK differently than other error codes.
Fix this by returning the actual error code.

Not sure if this is strictly needed, as the cqe error is set just fine. But I guess some places also check return value of the issue path.

Applied.

Signature · 1 line
Jens Axboe
#3 lore raw
Quoted 10 lines · Jens Axboe
Quoted 5 lines · Kanchan Joshi

If ->uring_cmd returned an error value different from -EAGAIN or -EIOCBQUEUED, it gets overridden with IOU_OK. This invites trouble as caller (io_uring core code) handles IOU_OK differently than other error codes.
Fix this by returning the actual error code.

Not sure if this is strictly needed, as the cqe error is set just fine. But I guess some places also check return value of the issue path.

So I was testing iopoll support and ran into this issue - submission failed (expected one), control came back to this point, error code got converted to IOU_OK, and it started polling endlessly for a command that never got submitted.
io_issue_sqe continued to invoke io_iopoll_req_issued() rather than bailing out.

maintainer
#4 lore raw
Quoted 12 lines · Kanchan Joshi
Quoted 10 lines · Jens Axboe
Quoted 5 lines · Kanchan Joshi

If ->uring_cmd returned an error value different from -EAGAIN or -EIOCBQUEUED, it gets overridden with IOU_OK. This invites trouble as caller (io_uring core code) handles IOU_OK differently than other error codes.
Fix this by returning the actual error code.

Not sure if this is strictly needed, as the cqe error is set just fine. But I guess some places also check return value of the issue path.

Quoted 6 lines

So I was testing iopoll support and ran into this issue - submission failed (expected one), control came back to this point, error code got converted to IOU_OK, and it started polling endlessly for a command that never got submitted.
io_issue_sqe continued to invoke io_iopoll_req_issued() rather than bailing out.

Ah ok, yes for iopoll it'd make a difference...

Signature · 1 line
Jens Axboe