diff options
author | Christophe Saout <christophe@saout.de> | 2004-05-25 23:25:49 -0700 |
---|---|---|
committer | Dmitry Torokhov <dtor_core@ameritech.net> | 2004-05-25 23:25:49 -0700 |
commit | db85e9905622825aff3e661ab9128aab9c72b810 (patch) | |
tree | c993a4652f0e1dccf5afd6e49ab8e698754b6cb2 /crypto | |
parent | d1510edaee892d13ea18465253b71fae156d1e52 (diff) | |
download | history-db85e9905622825aff3e661ab9128aab9c72b810.tar.gz |
[CRYPTO]: Fix two scatterwalk problems.
- 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).
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/cipher.c | 7 | ||||
-rw-r--r-- | crypto/scatterwalk.h | 1 |
2 files changed, 5 insertions, 3 deletions
diff --git a/crypto/cipher.c b/crypto/cipher.c index 9abe5b9ea9fb41..cdcf3472e9af37 100644 --- a/crypto/cipher.c +++ b/crypto/cipher.c @@ -68,19 +68,20 @@ static int crypt(struct crypto_tfm *tfm, for(;;) { u8 *src_p, *dst_p; + int in_place; scatterwalk_map(&walk_in, 0); scatterwalk_map(&walk_out, 1); src_p = scatterwalk_whichbuf(&walk_in, bsize, tmp_src); dst_p = scatterwalk_whichbuf(&walk_out, bsize, tmp_dst); + in_place = scatterwalk_samebuf(&walk_in, &walk_out, + src_p, dst_p); nbytes -= bsize; scatterwalk_copychunks(src_p, &walk_in, bsize, 0); - prfn(tfm, dst_p, src_p, crfn, enc, info, - scatterwalk_samebuf(&walk_in, &walk_out, - src_p, dst_p)); + prfn(tfm, dst_p, src_p, crfn, enc, info, in_place); scatterwalk_done(&walk_in, 0, nbytes); diff --git a/crypto/scatterwalk.h b/crypto/scatterwalk.h index 4d56c9217e12da..b16446519017f3 100644 --- a/crypto/scatterwalk.h +++ b/crypto/scatterwalk.h @@ -38,6 +38,7 @@ static inline int scatterwalk_samebuf(struct scatter_walk *walk_in, void *src_p, void *dst_p) { return walk_in->page == walk_out->page && + walk_in->offset == walk_out->offset && walk_in->data == src_p && walk_out->data == dst_p; } |