* FAILED: patch "[PATCH] io_uring/rw: fix missing ERESTARTSYS conversion in read paths" failed to apply to 6.12-stable tree
@ 2026-07-29 13:50 gregkh
2026-07-29 16:35 ` Jens Axboe
0 siblings, 1 reply; 7+ messages in thread
From: gregkh @ 2026-07-29 13:50 UTC (permalink / raw)
To: yi1tang.yang, axboe; +Cc: stable
The patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x ab05caca123c6d0b41850b7c05b246e4dca4a770
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026072912-manpower-thrift-f2fd@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From ab05caca123c6d0b41850b7c05b246e4dca4a770 Mon Sep 17 00:00:00 2001
From: Yitang Yang <yi1tang.yang@gmail.com>
Date: Wed, 22 Jul 2026 20:45:51 +0800
Subject: [PATCH] io_uring/rw: fix missing ERESTARTSYS conversion in read paths
Both read and write may receive internal restart error codes from
the filesystem layer and should be converted to -EINTR. However,
when multishot read support was added, the error code normalization
was lost for both io_read() and io_read_mshot().
Extract the conversion into io_fixup_restart_res() and apply it
in all three locations: io_rw_done(), io_read(), and io_read_mshot().
Fixes: a08d195b586a ("io_uring/rw: split io_read() into a helper")
Cc: stable@vger.kernel.org
Signed-off-by: Yitang Yang <yi1tang.yang@gmail.com>
Link: https://patch.msgid.link/20260722124551.130563-1-yi1tang.yang@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/io_uring/rw.c b/io_uring/rw.c
index 63b6519e498c..95038cfda615 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -615,6 +615,24 @@ static void io_complete_rw_iopoll(struct kiocb *kiocb, long res)
smp_store_release(&req->iopoll_completed, 1);
}
+static inline ssize_t io_fixup_restart_res(ssize_t ret)
+{
+ switch (ret) {
+ case -ERESTARTSYS:
+ case -ERESTARTNOINTR:
+ case -ERESTARTNOHAND:
+ case -ERESTART_RESTARTBLOCK:
+ /*
+ * We can't just restart the syscall, since previously
+ * submitted sqes may already be in progress. Just fail
+ * this IO with EINTR.
+ */
+ return -EINTR;
+ default:
+ return ret;
+ }
+}
+
static inline void io_rw_done(struct io_kiocb *req, ssize_t ret)
{
struct io_rw *rw = io_kiocb_to_cmd(req, struct io_rw);
@@ -624,21 +642,8 @@ static inline void io_rw_done(struct io_kiocb *req, ssize_t ret)
return;
/* transform internal restart error codes */
- if (unlikely(ret < 0)) {
- switch (ret) {
- case -ERESTARTSYS:
- case -ERESTARTNOINTR:
- case -ERESTARTNOHAND:
- case -ERESTART_RESTARTBLOCK:
- /*
- * We can't just restart the syscall, since previously
- * submitted sqes may already be in progress. Just fail
- * this IO with EINTR.
- */
- ret = -EINTR;
- break;
- }
- }
+ if (unlikely(ret < 0))
+ ret = io_fixup_restart_res(ret);
if (req->flags & REQ_F_IOPOLL)
io_complete_rw_iopoll(&rw->kiocb, ret);
@@ -1034,7 +1039,8 @@ int io_read(struct io_kiocb *req, unsigned int issue_flags)
if (req->flags & REQ_F_BUFFERS_COMMIT)
io_kbuf_recycle(req, sel.buf_list, issue_flags);
- return ret;
+
+ return io_fixup_restart_res(ret);
}
int io_read_mshot(struct io_kiocb *req, unsigned int issue_flags)
@@ -1068,8 +1074,10 @@ int io_read_mshot(struct io_kiocb *req, unsigned int issue_flags)
return IOU_RETRY;
} else if (ret <= 0) {
io_kbuf_recycle(req, sel.buf_list, issue_flags);
- if (ret < 0)
+ if (ret < 0) {
+ ret = io_fixup_restart_res(ret);
req_set_fail(req);
+ }
} else if (!(req->flags & REQ_F_APOLL_MULTISHOT)) {
cflags = io_put_kbuf(req, ret, sel.buf_list);
} else {
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: FAILED: patch "[PATCH] io_uring/rw: fix missing ERESTARTSYS conversion in read paths" failed to apply to 6.12-stable tree
2026-07-29 13:50 FAILED: patch "[PATCH] io_uring/rw: fix missing ERESTARTSYS conversion in read paths" failed to apply to 6.12-stable tree gregkh
@ 2026-07-29 16:35 ` Jens Axboe
2026-07-29 16:44 ` Jens Axboe
2026-08-02 3:15 ` Sasha Levin
0 siblings, 2 replies; 7+ messages in thread
From: Jens Axboe @ 2026-07-29 16:35 UTC (permalink / raw)
To: gregkh, yi1tang.yang; +Cc: stable
On 7/29/26 7:50 AM, gregkh@linuxfoundation.org wrote:
>
> The patch below does not apply to the 6.12-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.
>
> To reproduce the conflict and resubmit, you may use the following commands:
>
> git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
> git checkout FETCH_HEAD
> git cherry-pick -x ab05caca123c6d0b41850b7c05b246e4dca4a770
> # <resolve conflicts, build, test, etc.>
> git commit -s
> git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026072912-manpower-thrift-f2fd@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Seems that's already in 6.12-stable?
--
Jens Axboe
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: FAILED: patch "[PATCH] io_uring/rw: fix missing ERESTARTSYS conversion in read paths" failed to apply to 6.12-stable tree
2026-07-29 16:35 ` Jens Axboe
@ 2026-07-29 16:44 ` Jens Axboe
2026-07-29 17:39 ` Jens Axboe
2026-08-02 3:15 ` Sasha Levin
1 sibling, 1 reply; 7+ messages in thread
From: Jens Axboe @ 2026-07-29 16:44 UTC (permalink / raw)
To: gregkh, yi1tang.yang; +Cc: stable
On 7/29/26 10:35 AM, Jens Axboe wrote:
> On 7/29/26 7:50 AM, gregkh@linuxfoundation.org wrote:
>>
>> The patch below does not apply to the 6.12-stable tree.
>> If someone wants it applied there, or to any other stable or longterm
>> tree, then please email the backport, including the original git commit
>> id to <stable@vger.kernel.org>.
>>
>> To reproduce the conflict and resubmit, you may use the following commands:
>>
>> git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
>> git checkout FETCH_HEAD
>> git cherry-pick -x ab05caca123c6d0b41850b7c05b246e4dca4a770
>> # <resolve conflicts, build, test, etc.>
>> git commit -s
>> git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026072912-manpower-thrift-f2fd@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
>
> Seems that's already in 6.12-stable?
No sorry, I'm blind. I'll take care of this and the 6.6 one.
--
Jens Axboe
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: FAILED: patch "[PATCH] io_uring/rw: fix missing ERESTARTSYS conversion in read paths" failed to apply to 6.12-stable tree
2026-07-29 16:44 ` Jens Axboe
@ 2026-07-29 17:39 ` Jens Axboe
0 siblings, 0 replies; 7+ messages in thread
From: Jens Axboe @ 2026-07-29 17:39 UTC (permalink / raw)
To: gregkh, yi1tang.yang; +Cc: stable
[-- Attachment #1: Type: text/plain, Size: 1053 bytes --]
On 7/29/26 10:44 AM, Jens Axboe wrote:
> On 7/29/26 10:35 AM, Jens Axboe wrote:
>> On 7/29/26 7:50 AM, gregkh@linuxfoundation.org wrote:
>>>
>>> The patch below does not apply to the 6.12-stable tree.
>>> If someone wants it applied there, or to any other stable or longterm
>>> tree, then please email the backport, including the original git commit
>>> id to <stable@vger.kernel.org>.
>>>
>>> To reproduce the conflict and resubmit, you may use the following commands:
>>>
>>> git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
>>> git checkout FETCH_HEAD
>>> git cherry-pick -x ab05caca123c6d0b41850b7c05b246e4dca4a770
>>> # <resolve conflicts, build, test, etc.>
>>> git commit -s
>>> git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026072912-manpower-thrift-f2fd@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
>>
>> Seems that's already in 6.12-stable?
>
> No sorry, I'm blind. I'll take care of this and the 6.6 one.
Here's the 6.12-stable one, sorry for the mixed emails.
--
Jens Axboe
[-- Attachment #2: 0001-io_uring-rw-fix-missing-ERESTARTSYS-conversion-in-re.patch --]
[-- Type: text/x-patch, Size: 3194 bytes --]
From 694056a4170df694f0689aa62d413f8728638c9b Mon Sep 17 00:00:00 2001
From: Yitang Yang <yi1tang.yang@gmail.com>
Date: Wed, 22 Jul 2026 20:45:51 +0800
Subject: [PATCH] io_uring/rw: fix missing ERESTARTSYS conversion in read paths
Commit ab05caca123c6d0b41850b7c05b246e4dca4a770 upstream.
Both read and write may receive internal restart error codes from
the filesystem layer and should be converted to -EINTR. However,
when multishot read support was added, the error code normalization
was lost for both io_read() and io_read_mshot().
Extract the conversion into io_fixup_restart_res() and apply it
in all three locations: io_rw_done(), io_read(), and io_read_mshot().
Fixes: a08d195b586a ("io_uring/rw: split io_read() into a helper")
Cc: stable@vger.kernel.org
Signed-off-by: Yitang Yang <yi1tang.yang@gmail.com>
Link: https://patch.msgid.link/20260722124551.130563-1-yi1tang.yang@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
io_uring/rw.c | 42 +++++++++++++++++++++++++-----------------
1 file changed, 25 insertions(+), 17 deletions(-)
diff --git a/io_uring/rw.c b/io_uring/rw.c
index a744cb5d235a..a74664c4a05e 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -560,6 +560,24 @@ static void io_complete_rw_iopoll(struct kiocb *kiocb, long res)
smp_store_release(&req->iopoll_completed, 1);
}
+static inline ssize_t io_fixup_restart_res(ssize_t ret)
+{
+ switch (ret) {
+ case -ERESTARTSYS:
+ case -ERESTARTNOINTR:
+ case -ERESTARTNOHAND:
+ case -ERESTART_RESTARTBLOCK:
+ /*
+ * We can't just restart the syscall, since previously
+ * submitted sqes may already be in progress. Just fail
+ * this IO with EINTR.
+ */
+ return -EINTR;
+ default:
+ return ret;
+ }
+}
+
static inline void io_rw_done(struct kiocb *kiocb, ssize_t ret)
{
/* IO was queued async, completion will happen later */
@@ -567,21 +585,8 @@ static inline void io_rw_done(struct kiocb *kiocb, ssize_t ret)
return;
/* transform internal restart error codes */
- if (unlikely(ret < 0)) {
- switch (ret) {
- case -ERESTARTSYS:
- case -ERESTARTNOINTR:
- case -ERESTARTNOHAND:
- case -ERESTART_RESTARTBLOCK:
- /*
- * We can't just restart the syscall, since previously
- * submitted sqes may already be in progress. Just fail
- * this IO with EINTR.
- */
- ret = -EINTR;
- break;
- }
- }
+ if (unlikely(ret < 0))
+ ret = io_fixup_restart_res(ret);
INDIRECT_CALL_2(kiocb->ki_complete, io_complete_rw_iopoll,
io_complete_rw, kiocb, ret);
@@ -961,7 +966,8 @@ int io_read(struct io_kiocb *req, unsigned int issue_flags)
if (req->flags & REQ_F_BUFFERS_COMMIT)
io_kbuf_recycle(req, sel.buf_list, issue_flags);
- return ret;
+
+ return io_fixup_restart_res(ret);
}
int io_read_mshot(struct io_kiocb *req, unsigned int issue_flags)
@@ -995,8 +1001,10 @@ int io_read_mshot(struct io_kiocb *req, unsigned int issue_flags)
return -EAGAIN;
} else if (ret <= 0) {
io_kbuf_recycle(req, sel.buf_list, issue_flags);
- if (ret < 0)
+ if (ret < 0) {
+ ret = io_fixup_restart_res(ret);
req_set_fail(req);
+ }
} else if (!(req->flags & REQ_F_APOLL_MULTISHOT)) {
cflags = io_put_kbuf(req, ret, sel.buf_list);
} else {
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: FAILED: patch "[PATCH] io_uring/rw: fix missing ERESTARTSYS conversion in read paths" failed to apply to 6.12-stable tree
2026-07-29 16:35 ` Jens Axboe
2026-07-29 16:44 ` Jens Axboe
@ 2026-08-02 3:15 ` Sasha Levin
2026-08-02 4:18 ` Jens Axboe
1 sibling, 1 reply; 7+ messages in thread
From: Sasha Levin @ 2026-08-02 3:15 UTC (permalink / raw)
To: gregkh, yi1tang.yang; +Cc: Sasha Levin, stable, Jens Axboe
On Wed, Jul 29, 2026 at 10:35:51AM -0600, Jens Axboe wrote:
>Seems that's already in 6.12-stable?
Not quite - stable/linux-6.12.y has no io_fixup_restart_res() at all.
What 6.12 does already have is the older inline ERESTART* -> -EINTR
switch inside io_rw_done(), which is the code ab05caca123c refactors
rather than the fix itself. The actual bug is still there: io_read()
ends with a bare "return ret;" after __io_read(), and io_read_mshot()'s
"ret <= 0" branch only does req_set_fail(), so an -ERESTARTSYS coming
out of __io_read() reaches userspace as -512 unconverted.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: FAILED: patch "[PATCH] io_uring/rw: fix missing ERESTARTSYS conversion in read paths" failed to apply to 6.12-stable tree
2026-08-02 3:15 ` Sasha Levin
@ 2026-08-02 4:18 ` Jens Axboe
2026-08-03 20:46 ` Sasha Levin
0 siblings, 1 reply; 7+ messages in thread
From: Jens Axboe @ 2026-08-02 4:18 UTC (permalink / raw)
To: Sasha Levin, gregkh, yi1tang.yang; +Cc: stable
On 8/1/26 9:15 PM, Sasha Levin wrote:
> On Wed, Jul 29, 2026 at 10:35:51AM -0600, Jens Axboe wrote:
>> Seems that's already in 6.12-stable?
>
> Not quite - stable/linux-6.12.y has no io_fixup_restart_res() at all.
>
> What 6.12 does already have is the older inline ERESTART* -> -EINTR
> switch inside io_rw_done(), which is the code ab05caca123c refactors
> rather than the fix itself. The actual bug is still there: io_read()
> ends with a bare "return ret;" after __io_read(), and io_read_mshot()'s
> "ret <= 0" branch only does req_set_fail(), so an -ERESTARTSYS coming
> out of __io_read() reaches userspace as -512 unconverted.
Right, this original email was superseded by the later ones. As long
as the sent out patches got queued up, we should be fine.
--
Jens Axboe
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: FAILED: patch "[PATCH] io_uring/rw: fix missing ERESTARTSYS conversion in read paths" failed to apply to 6.12-stable tree
2026-08-02 4:18 ` Jens Axboe
@ 2026-08-03 20:46 ` Sasha Levin
0 siblings, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2026-08-03 20:46 UTC (permalink / raw)
To: gregkh, yi1tang.yang; +Cc: Sasha Levin, stable, Jens Axboe
On Sat, Aug 01, 2026 at 10:18:11PM -0600, Jens Axboe wrote:
> Right, this original email was superseded by the later ones. As long
> as the sent out patches got queued up, we should be fine.
They did - "io_uring/rw: fix missing ERESTARTSYS conversion in read
paths" is queued for 6.12 (and for 6.1 as well).
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-08-03 20:47 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-29 13:50 FAILED: patch "[PATCH] io_uring/rw: fix missing ERESTARTSYS conversion in read paths" failed to apply to 6.12-stable tree gregkh
2026-07-29 16:35 ` Jens Axboe
2026-07-29 16:44 ` Jens Axboe
2026-07-29 17:39 ` Jens Axboe
2026-08-02 3:15 ` Sasha Levin
2026-08-02 4:18 ` Jens Axboe
2026-08-03 20:46 ` Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox