<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">
From: Christophe Saout &lt;christophe@saout.de&gt;

- After calling scatterwalk_copychunks walk_in might point to the next
  page which will break scatterwalk_samebuf (in this case src_p should
  point to tmp_src anyway and scatterwalk_samembuf returns 0).

- scatterwalk_samebuf should also check for equal offsets inside the page
  (just bad for performance in some cases).


---

 25-akpm/crypto/cipher.c      |    7 ++++---
 25-akpm/crypto/scatterwalk.h |    1 +
 2 files changed, 5 insertions(+), 3 deletions(-)

diff -puN crypto/cipher.c~crypto-scatterwalk-fixes crypto/cipher.c
--- 25/crypto/cipher.c~crypto-scatterwalk-fixes	2004-05-24 01:20:33.432054608 -0700
+++ 25-akpm/crypto/cipher.c	2004-05-24 01:20:33.437053848 -0700
@@ -68,19 +68,20 @@ static int crypt(struct crypto_tfm *tfm,
 
 	for(;;) {
 		u8 *src_p, *dst_p;
+		int in_place;
 
 		scatterwalk_map(&amp;walk_in, 0);
 		scatterwalk_map(&amp;walk_out, 1);
 		src_p = scatterwalk_whichbuf(&amp;walk_in, bsize, tmp_src);
 		dst_p = scatterwalk_whichbuf(&amp;walk_out, bsize, tmp_dst);
+		in_place = scatterwalk_samebuf(&amp;walk_in, &amp;walk_out,
+					       src_p, dst_p);
 
 		nbytes -= bsize;
 
 		scatterwalk_copychunks(src_p, &amp;walk_in, bsize, 0);
 
-		prfn(tfm, dst_p, src_p, crfn, enc, info,
-		     scatterwalk_samebuf(&amp;walk_in, &amp;walk_out,
-					 src_p, dst_p));
+		prfn(tfm, dst_p, src_p, crfn, enc, info, in_place);
 
 		scatterwalk_done(&amp;walk_in, 0, nbytes);
 
diff -puN crypto/scatterwalk.h~crypto-scatterwalk-fixes crypto/scatterwalk.h
--- 25/crypto/scatterwalk.h~crypto-scatterwalk-fixes	2004-05-24 01:20:33.434054304 -0700
+++ 25-akpm/crypto/scatterwalk.h	2004-05-24 01:20:33.438053696 -0700
@@ -38,6 +38,7 @@ static inline int scatterwalk_samebuf(st
 				      void *src_p, void *dst_p)
 {
 	return walk_in-&gt;page == walk_out-&gt;page &amp;&amp;
+	       walk_in-&gt;offset == walk_out-&gt;offset &amp;&amp;
 	       walk_in-&gt;data == src_p &amp;&amp; walk_out-&gt;data == dst_p;
 }
 

_
</pre></body></html>