Skip to contentSkip to conversation

cifs: Fix kmap_local_page() unmapping

PATCH In review Ira Weiny 4 participants 4 messages Dec 29, 2022 – Jan 4, 2023

Subsystems (2)
lore
Share & tools
lore

Ira Weiny

author
#0 lore raw

PATCH 1/1 cifs: Fix kmap_local_page() unmapping

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 <[email protected]>
Cc Steve French <[email protected]>
Cc "Fabio M. De Francesco" <[email protected]>
---
 fs/cifs/smb2ops.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
fs/cifs/smb2ops.c +2 -7
index dc160de7a6de..0d7e9bcd9f34 100644
@@ -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);
 		}
 	}
 

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

Best regards,

Signature · 1 line
Ira Weiny <[email protected]>
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Ira Weiny

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 <[email protected]>
Cc Steve French <[email protected]>
Cc "Fabio M. De Francesco" <[email protected]>
Quoted 3 lines
---
 fs/cifs/smb2ops.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
Reviewed-by on v1 1/1
#2 lore raw
In reply to Ira Weiny

fs/cifs/smb2ops.c smb3_init_transform_rq(struct TCP_Server_Info

Quoted 22 lines · 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 <[email protected]>
Cc Steve French <[email protected]>
Cc "Fabio M. De Francesco" <[email protected]>
---
 fs/cifs/smb2ops.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
fs/cifs/smb2ops.c +0 -0
index dc160de7a6de..0d7e9bcd9f34 100644
@@ -4488,17 +4488,12 @@ smb3_init_transform_rq(struct TCP_Server_Info 

*server,

fs/cifs/smb2ops.c smb3_init_transform_rq(struct TCP_Server_Info *server, int num_rqst,

Quoted 10 lines
fs/cifs/smb2ops.c +0 -2
 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;

fs/cifs/smb2ops.c smb3_init_transform_rq(struct TCP_Server_Info · line 4498

Quoted 1 line
fs/cifs/smb2ops.c +0 -1
-			src = kmap_local_page(old->rq_pages[j]) + 

offset;

fs/cifs/smb2ops.c smb3_init_transform_rq(struct TCP_Server_Info *server, int num_rqst, · line 4499

Quoted 7 lines
fs/cifs/smb2ops.c +2 -4
-
-			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

Quoted 11 lines
fs/cifs/smb2ops.c +0 -0
 		}

}

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

Best regards,
--
Ira Weiny <[email protected]>

#3 lore raw

merged into cifs-2.6.git for-next pending testing

Quoted 66 lines · Fabio M. De Francesco

fs/cifs/smb2ops.c smb3_init_transform_rq(struct TCP_Server_Info

Quoted 22 lines · 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 <[email protected]>
Cc Steve French <[email protected]>
Cc "Fabio M. De Francesco" <[email protected]>
---
 fs/cifs/smb2ops.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
fs/cifs/smb2ops.c +0 -0
index dc160de7a6de..0d7e9bcd9f34 100644
@@ -4488,17 +4488,12 @@ smb3_init_transform_rq(struct TCP_Server_Info

*server,

fs/cifs/smb2ops.c smb3_init_transform_rq(struct TCP_Server_Info *server, int num_rqst,

Quoted 10 lines
fs/cifs/smb2ops.c +0 -2
 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;

fs/cifs/smb2ops.c smb3_init_transform_rq(struct TCP_Server_Info · line 4498

Quoted 1 line
fs/cifs/smb2ops.c +0 -1
-                     src = kmap_local_page(old->rq_pages[j]) +

offset;

fs/cifs/smb2ops.c smb3_init_transform_rq(struct TCP_Server_Info *server, int num_rqst, · line 4499

Quoted 7 lines
fs/cifs/smb2ops.c +2 -4
-
-                     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

Quoted 11 lines
fs/cifs/smb2ops.c +0 -0
              }
      }

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

Best regards,
--
Ira Weiny <[email protected]>

Signature · 3 lines
Thanks,

Steve