Skip to contentSkip to conversation

cifs: Fix signature miscalculation

PATCH In review David Howells 3 participants 3 messages Sep 12, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: Fix signature miscalculation

Fix the calculation of packet signatures by adding the offset into a page in the read or write data payload when hashing the pages from it.

Fixes 39bc58203f04 ("cifs: Add a function to Hash the contents of an iterator")
cc Steve French <[email protected]>
cc Paulo Alcantara <[email protected]>
cc Shyam Prasad N <[email protected]>
cc Rohith Surabattula <[email protected]>
cc Jeff Layton <[email protected]>
---
 fs/smb/client/cifsencrypt.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/client/cifsencrypt.c +1 -1
index 6322f0f68a17..b0473c2567fe 100644
@@ -129,7 +129,7 @@ static ssize_t cifs_shash_xarray(const struct iov_iter *iter, ssize_t maxsize,
 			for (j = foffset / PAGE_SIZE; j < npages; j++) {
 				len = min_t(size_t, maxsize, PAGE_SIZE - offset);
 				p = kmap_local_page(folio_page(folio, j));
-				ret = crypto_shash_update(shash, p, len);
+				ret = crypto_shash_update(shash, p + offset, len);
 				kunmap_local(p);
 				if (ret < 0)
 					return ret;
#1 lore raw

looks like this fixes the problem - merged into cifs-2.6.git for-next

Quoted 33 lines · David Howells

Fix the calculation of packet signatures by adding the offset into a page in the read or write data payload when hashing the pages from it.

Fixes 39bc58203f04 ("cifs: Add a function to Hash the contents of an iterator")
cc Steve French <[email protected]>
cc Paulo Alcantara <[email protected]>
cc Shyam Prasad N <[email protected]>
cc Rohith Surabattula <[email protected]>
cc Jeff Layton <[email protected]>
---
 fs/smb/client/cifsencrypt.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/client/cifsencrypt.c +1 -1
index 6322f0f68a17..b0473c2567fe 100644
@@ -129,7 +129,7 @@ static ssize_t cifs_shash_xarray(const struct iov_iter *iter, ssize_t maxsize,
                        for (j = foffset / PAGE_SIZE; j < npages; j++) {
                                len = min_t(size_t, maxsize, PAGE_SIZE - offset);
                                p = kmap_local_page(folio_page(folio, j));
-                               ret = crypto_shash_update(shash, p, len);
+                               ret = crypto_shash_update(shash, p + offset, len);
                                kunmap_local(p);
                                if (ret < 0)
                                        return ret;
Signature · 3 lines
Thanks,

Steve
reviewer Reviewed-by
#2 lore raw

Ouch! Thanks for this, and just in time for next week's IOLab. :)

Tom.

Quoted 38 lines · Steve French

looks like this fixes the problem - merged into cifs-2.6.git for-next

Quoted 33 lines · David Howells

Fix the calculation of packet signatures by adding the offset into a page in the read or write data payload when hashing the pages from it.

Fixes 39bc58203f04 ("cifs: Add a function to Hash the contents of an iterator")
cc Steve French <[email protected]>
cc Paulo Alcantara <[email protected]>
cc Shyam Prasad N <[email protected]>
cc Rohith Surabattula <[email protected]>
cc Jeff Layton <[email protected]>
---
  fs/smb/client/cifsencrypt.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/client/cifsencrypt.c +1 -1
index 6322f0f68a17..b0473c2567fe 100644
@@ -129,7 +129,7 @@ static ssize_t cifs_shash_xarray(const struct iov_iter *iter, ssize_t maxsize,
                         for (j = foffset / PAGE_SIZE; j < npages; j++) {
                                 len = min_t(size_t, maxsize, PAGE_SIZE - offset);
                                 p = kmap_local_page(folio_page(folio, j));
-                               ret = crypto_shash_update(shash, p, len);
+                               ret = crypto_shash_update(shash, p + offset, len);
                                 kunmap_local(p);
                                 if (ret < 0)
                                         return ret;