All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] io_uring: fix truncated async read/readv and write/writev retry
@ 2020-03-11 18:30 Jens Axboe
  2020-03-12  9:36 ` Stefan Metzmacher
  0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2020-03-11 18:30 UTC (permalink / raw)
  To: io-uring

Ensure we keep the truncated value, if we did truncate it. If not, we
might read/write more than the registered buffer size.

Also for retry, ensure that we return the truncated mapped value for
the vectorized versions of the read/write commands.

Signed-off-by: Jens Axboe <axboe@kernel.dk>

---

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 9f1a462eb780..55afae6f0cf4 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2360,6 +2360,7 @@ static ssize_t io_import_iovec(int rw, struct io_kiocb *req,
 				*iovec = NULL;
 				return PTR_ERR(buf);
 			}
+			req->rw.len = sqe_len;
 		}
 
 		ret = import_single_range(rw, buf, sqe_len, *iovec, iter);
@@ -2379,8 +2380,10 @@ static ssize_t io_import_iovec(int rw, struct io_kiocb *req,
 
 	if (req->flags & REQ_F_BUFFER_SELECT) {
 		ret = io_iov_buffer_select(req, *iovec, needs_lock);
-		if (!ret)
-			iov_iter_init(iter, rw, *iovec, 1, (*iovec)->iov_len);
+		if (!ret) {
+			ret = (*iovec)->iov_len;
+			iov_iter_init(iter, rw, *iovec, 1, ret);
+		}
 		*iovec = NULL;
 		return ret;
 	}

-- 
Jens Axboe


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

* Re: [PATCH] io_uring: fix truncated async read/readv and write/writev retry
  2020-03-11 18:30 [PATCH] io_uring: fix truncated async read/readv and write/writev retry Jens Axboe
@ 2020-03-12  9:36 ` Stefan Metzmacher
  2020-03-12 12:58   ` Jens Axboe
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Metzmacher @ 2020-03-12  9:36 UTC (permalink / raw)
  To: Jens Axboe, io-uring


[-- Attachment #1.1: Type: text/plain, Size: 1318 bytes --]

Hi Jens,

I haven't looked at the change in detail, but I'm wondering if this
would be needed in stable too?

metze

Am 11.03.20 um 19:30 schrieb Jens Axboe:
> Ensure we keep the truncated value, if we did truncate it. If not, we
> might read/write more than the registered buffer size.
> 
> Also for retry, ensure that we return the truncated mapped value for
> the vectorized versions of the read/write commands.
> 
> Signed-off-by: Jens Axboe <axboe@kernel.dk>
> 
> ---
> 
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index 9f1a462eb780..55afae6f0cf4 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -2360,6 +2360,7 @@ static ssize_t io_import_iovec(int rw, struct io_kiocb *req,
>  				*iovec = NULL;
>  				return PTR_ERR(buf);
>  			}
> +			req->rw.len = sqe_len;
>  		}
>  
>  		ret = import_single_range(rw, buf, sqe_len, *iovec, iter);
> @@ -2379,8 +2380,10 @@ static ssize_t io_import_iovec(int rw, struct io_kiocb *req,
>  
>  	if (req->flags & REQ_F_BUFFER_SELECT) {
>  		ret = io_iov_buffer_select(req, *iovec, needs_lock);
> -		if (!ret)
> -			iov_iter_init(iter, rw, *iovec, 1, (*iovec)->iov_len);
> +		if (!ret) {
> +			ret = (*iovec)->iov_len;
> +			iov_iter_init(iter, rw, *iovec, 1, ret);
> +		}
>  		*iovec = NULL;
>  		return ret;
>  	}
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] io_uring: fix truncated async read/readv and write/writev retry
  2020-03-12  9:36 ` Stefan Metzmacher
@ 2020-03-12 12:58   ` Jens Axboe
  0 siblings, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2020-03-12 12:58 UTC (permalink / raw)
  To: Stefan Metzmacher, io-uring

On 3/12/20 3:36 AM, Stefan Metzmacher wrote:
> Hi Jens,
> 
> I haven't looked at the change in detail, but I'm wondering if this
> would be needed in stable too?

It's just for the buffer select stuff, so won't impact 5.6 or
earlier.

-- 
Jens Axboe


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

end of thread, other threads:[~2020-03-12 12:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-11 18:30 [PATCH] io_uring: fix truncated async read/readv and write/writev retry Jens Axboe
2020-03-12  9:36 ` Stefan Metzmacher
2020-03-12 12:58   ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.