[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CANT5p=r7usL_YOBxRoiVCrZpZr2+-FLjs1Jg_T6R5==HJQ0epg@mail.gmail.com>
Date: Tue, 23 May 2023 22:00:55 +0530
From: Shyam Prasad N <nspmangalore@...il.com>
To: David Howells <dhowells@...hat.com>
Cc: Shyam Prasad N <sprasad@...rosoft.com>,
Steve French <smfrench@...il.com>,
Rohith Surabattula <rohiths.msft@...il.com>,
Paulo Alcantara <pc@...guebit.com>,
Tom Talpey <tom@...pey.com>, Jeff Layton <jlayton@...nel.org>,
linux-cifs@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] cifs: Fix cifs_limit_bvec_subset() to correctly check
the maxmimum size
On Tue, May 23, 2023 at 6:24 PM David Howells <dhowells@...hat.com> wrote:
>
> Fix cifs_limit_bvec_subset() so that it limits the span to the maximum
> specified and won't return with a size greater than max_size.
>
> Fixes: d08089f649a0 ("cifs: Change the I/O paths to use an iterator rather than a page list")
> Reported-by: Shyam Prasad N <sprasad@...rosoft.com>
> Signed-off-by: David Howells <dhowells@...hat.com>
> cc: Steve French <smfrench@...il.com>
> cc: Rohith Surabattula <rohiths.msft@...il.com>
> cc: Paulo Alcantara <pc@...guebit.com>
> cc: Tom Talpey <tom@...pey.com>
> cc: Jeff Layton <jlayton@...nel.org>
> cc: linux-cifs@...r.kernel.org
> cc: linux-fsdevel@...r.kernel.org
> ---
> fs/cifs/file.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/cifs/file.c b/fs/cifs/file.c
> index ba7f2e09d6c8..df88b8c04d03 100644
> --- a/fs/cifs/file.c
> +++ b/fs/cifs/file.c
> @@ -3353,9 +3353,10 @@ static size_t cifs_limit_bvec_subset(const struct iov_iter *iter, size_t max_siz
> while (n && ix < nbv) {
> len = min3(n, bvecs[ix].bv_len - skip, max_size);
> span += len;
> + max_size -= len;
> nsegs++;
> ix++;
> - if (span >= max_size || nsegs >= max_segs)
> + if (max_size == 0 || nsegs >= max_segs)
> break;
> skip = 0;
> n -= len;
>
Looks good to me.
--
Regards,
Shyam
Powered by blists - more mailing lists