diff mbox series

cifs: Fix kmap_local_page() unmapping

Message ID 20221229-cifs-kmap-v1-1-c70d0e9a53eb@intel.com (mailing list archive)
State New, archived
Headers show
Series cifs: Fix kmap_local_page() unmapping | expand

Commit Message

Ira Weiny Dec. 29, 2022, 10:04 p.m. UTC
kmap_local_page() requires kunmap_local() to unmap the mapping.  In
addition memcpy_page() is provided to perform this common memcpy
pattern.

Replace the kmap_local_page() and broken kunmap() with memcpy_page()

Fixes: d406d26745ab ("cifs: skip alloc when request has no pages")
Cc: Paulo Alcantara <pc@cjr.nz>
Cc: Steve French <sfrench@samba.org>
Cc: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
 fs/cifs/smb2ops.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)


---
base-commit: 1b929c02afd37871d5afb9d498426f83432e71c2
change-id: 20221229-cifs-kmap-6700dabafcdf

Best regards,

Comments

Paulo Alcantara Dec. 29, 2022, 10:13 p.m. UTC | #1
Ira Weiny <ira.weiny@intel.com> writes:

> kmap_local_page() requires kunmap_local() to unmap the mapping.  In
> addition memcpy_page() is provided to perform this common memcpy
> pattern.
>
> Replace the kmap_local_page() and broken kunmap() with memcpy_page()
>
> Fixes: d406d26745ab ("cifs: skip alloc when request has no pages")
> Cc: Paulo Alcantara <pc@cjr.nz>
> Cc: Steve French <sfrench@samba.org>
> Cc: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
> Cc: linux-cifs@vger.kernel.org
> Cc: samba-technical@lists.samba.org
> Signed-off-by: Ira Weiny <ira.weiny@intel.com>
> ---
>  fs/cifs/smb2ops.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)

Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Fabio M. De Francesco Dec. 29, 2022, 10:25 p.m. UTC | #2
On giovedì 29 dicembre 2022 23:04:46 CET Ira Weiny wrote:
> kmap_local_page() requires kunmap_local() to unmap the mapping.  In
> addition memcpy_page() is provided to perform this common memcpy
> pattern.
> 
> Replace the kmap_local_page() and broken kunmap() with memcpy_page()
> 
> Fixes: d406d26745ab ("cifs: skip alloc when request has no pages")
> Cc: Paulo Alcantara <pc@cjr.nz>
> Cc: Steve French <sfrench@samba.org>
> Cc: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
> Cc: linux-cifs@vger.kernel.org
> Cc: samba-technical@lists.samba.org
> Signed-off-by: Ira Weiny <ira.weiny@intel.com>
> ---
>  fs/cifs/smb2ops.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
> index dc160de7a6de..0d7e9bcd9f34 100644
> --- a/fs/cifs/smb2ops.c
> +++ b/fs/cifs/smb2ops.c
> @@ -4488,17 +4488,12 @@ smb3_init_transform_rq(struct TCP_Server_Info 
*server,
> int num_rqst,
> 
>  		/* copy pages form the old */
>  		for (j = 0; j < npages; j++) {
> -			char *dst, *src;
>  			unsigned int offset, len;
> 
>  			rqst_page_get_length(new, j, &len, &offset);
> 
> -			dst = kmap_local_page(new->rq_pages[j]) + 
offset;
> -			src = kmap_local_page(old->rq_pages[j]) + 
offset;
> -
> -			memcpy(dst, src, len);
> -			kunmap(new->rq_pages[j]);
> -			kunmap(old->rq_pages[j]);
> +			memcpy_page(new->rq_pages[j], offset,
> +				    old->rq_pages[j], offset, len);
>
FWIW, it looks good to me...

Reviewed-by: Fabio M. De Francesco

Thanks,

Fabio
>  		}
>  	}
> 
> 
> ---
> base-commit: 1b929c02afd37871d5afb9d498426f83432e71c2
> change-id: 20221229-cifs-kmap-6700dabafcdf
> 
> Best regards,
> --
> Ira Weiny <ira.weiny@intel.com>
Steve French Jan. 4, 2023, 6:15 a.m. UTC | #3
merged into cifs-2.6.git for-next pending testing

On Thu, Dec 29, 2022 at 4:38 PM Fabio M. De Francesco
<fmdefrancesco@gmail.com> wrote:
>
> On giovedì 29 dicembre 2022 23:04:46 CET Ira Weiny wrote:
> > kmap_local_page() requires kunmap_local() to unmap the mapping.  In
> > addition memcpy_page() is provided to perform this common memcpy
> > pattern.
> >
> > Replace the kmap_local_page() and broken kunmap() with memcpy_page()
> >
> > Fixes: d406d26745ab ("cifs: skip alloc when request has no pages")
> > Cc: Paulo Alcantara <pc@cjr.nz>
> > Cc: Steve French <sfrench@samba.org>
> > Cc: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
> > Cc: linux-cifs@vger.kernel.org
> > Cc: samba-technical@lists.samba.org
> > Signed-off-by: Ira Weiny <ira.weiny@intel.com>
> > ---
> >  fs/cifs/smb2ops.c | 9 ++-------
> >  1 file changed, 2 insertions(+), 7 deletions(-)
> >
> > diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
> > index dc160de7a6de..0d7e9bcd9f34 100644
> > --- a/fs/cifs/smb2ops.c
> > +++ b/fs/cifs/smb2ops.c
> > @@ -4488,17 +4488,12 @@ smb3_init_transform_rq(struct TCP_Server_Info
> *server,
> > int num_rqst,
> >
> >               /* copy pages form the old */
> >               for (j = 0; j < npages; j++) {
> > -                     char *dst, *src;
> >                       unsigned int offset, len;
> >
> >                       rqst_page_get_length(new, j, &len, &offset);
> >
> > -                     dst = kmap_local_page(new->rq_pages[j]) +
> offset;
> > -                     src = kmap_local_page(old->rq_pages[j]) +
> offset;
> > -
> > -                     memcpy(dst, src, len);
> > -                     kunmap(new->rq_pages[j]);
> > -                     kunmap(old->rq_pages[j]);
> > +                     memcpy_page(new->rq_pages[j], offset,
> > +                                 old->rq_pages[j], offset, len);
> >
> FWIW, it looks good to me...
>
> Reviewed-by: Fabio M. De Francesco
>
> Thanks,
>
> Fabio
> >               }
> >       }
> >
> >
> > ---
> > base-commit: 1b929c02afd37871d5afb9d498426f83432e71c2
> > change-id: 20221229-cifs-kmap-6700dabafcdf
> >
> > Best regards,
> > --
> > Ira Weiny <ira.weiny@intel.com>
>
>
>
diff mbox series

Patch

diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index dc160de7a6de..0d7e9bcd9f34 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -4488,17 +4488,12 @@  smb3_init_transform_rq(struct TCP_Server_Info *server, int num_rqst,
 
 		/* copy pages form the old */
 		for (j = 0; j < npages; j++) {
-			char *dst, *src;
 			unsigned int offset, len;
 
 			rqst_page_get_length(new, j, &len, &offset);
 
-			dst = kmap_local_page(new->rq_pages[j]) + offset;
-			src = kmap_local_page(old->rq_pages[j]) + offset;
-
-			memcpy(dst, src, len);
-			kunmap(new->rq_pages[j]);
-			kunmap(old->rq_pages[j]);
+			memcpy_page(new->rq_pages[j], offset,
+				    old->rq_pages[j], offset, len);
 		}
 	}