public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* 5.19 and 5.15 stable patches
@ 2022-08-25 16:21 Jens Axboe
  2022-08-29  8:01 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Jens Axboe @ 2022-08-25 16:21 UTC (permalink / raw)
  To: stable; +Cc: song@kernel.org

[-- Attachment #1: Type: text/plain, Size: 115 bytes --]

Hi,

Backport of fix that went into 6.0-rc1 for 5.19-stable and
5.15-stable. Please apply, thanks!

-- 
Jens Axboe

[-- Attachment #2: 5.15-0001-io_uring-fix-issue-with-io_write-not-always-undoing-.patch --]
[-- Type: text/x-patch, Size: 1241 bytes --]

From 952c7ac49a59eb115790d1ec55974303c9d2f0fd Mon Sep 17 00:00:00 2001
From: Jens Axboe <axboe@kernel.dk>
Date: Thu, 25 Aug 2022 10:19:08 -0600
Subject: [PATCH] io_uring: fix issue with io_write() not always undoing
 sb_start_write()

commit e053aaf4da56cbf0afb33a0fda4a62188e2c0637 upstream.

This is actually an older issue, but we never used to hit the -EAGAIN
path before having done sb_start_write(). Make sure that we always call
kiocb_end_write() if we need to retry the write, so that we keep the
calls to sb_start_write() etc balanced.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/io_uring.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index a7097495b433..ccf9bd808273 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -3720,7 +3720,12 @@ static int io_write(struct io_kiocb *req, unsigned int issue_flags)
 copy_iov:
 		iov_iter_restore(iter, state);
 		ret = io_setup_async_rw(req, iovec, inline_vecs, iter, false);
-		return ret ?: -EAGAIN;
+		if (!ret) {
+			if (kiocb->ki_flags & IOCB_WRITE)
+				kiocb_end_write(req);
+			return -EAGAIN;
+		}
+		return ret;
 	}
 out_free:
 	/* it's reportedly faster than delegating the null check to kfree() */
-- 
2.35.1


[-- Attachment #3: 5.19-0001-io_uring-fix-issue-with-io_write-not-always-undoing-.patch --]
[-- Type: text/x-patch, Size: 1268 bytes --]

From e6ab6c526bab6020869d6d97eb46bec06b4fd287 Mon Sep 17 00:00:00 2001
From: Jens Axboe <axboe@kernel.dk>
Date: Thu, 25 Aug 2022 10:17:25 -0600
Subject: [PATCH] io_uring: fix issue with io_write() not always undoing
 sb_start_write()

commit e053aaf4da56cbf0afb33a0fda4a62188e2c0637 upstream.

This is actually an older issue, but we never used to hit the -EAGAIN
path before having done sb_start_write(). Make sure that we always call
kiocb_end_write() if we need to retry the write, so that we keep the
calls to sb_start_write() etc balanced.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 io_uring/io_uring.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 6a67dbf5195f..cd155b7e1346 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -4331,7 +4331,12 @@ static int io_write(struct io_kiocb *req, unsigned int issue_flags)
 copy_iov:
 		iov_iter_restore(&s->iter, &s->iter_state);
 		ret = io_setup_async_rw(req, iovec, s, false);
-		return ret ?: -EAGAIN;
+		if (!ret) {
+			if (kiocb->ki_flags & IOCB_WRITE)
+				kiocb_end_write(req);
+			return -EAGAIN;
+		}
+		return ret;
 	}
 out_free:
 	/* it's reportedly faster than delegating the null check to kfree() */
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-29  8:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-25 16:21 5.19 and 5.15 stable patches Jens Axboe
2022-08-29  8:01 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox