Commit db85e990 authored by Christophe Saout's avatar Christophe Saout Committed by Dmitry Torokhov

[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).
parent d1510eda
...@@ -68,19 +68,20 @@ static int crypt(struct crypto_tfm *tfm, ...@@ -68,19 +68,20 @@ static int crypt(struct crypto_tfm *tfm,
for(;;) { for(;;) {
u8 *src_p, *dst_p; u8 *src_p, *dst_p;
int in_place;
scatterwalk_map(&walk_in, 0); scatterwalk_map(&walk_in, 0);
scatterwalk_map(&walk_out, 1); scatterwalk_map(&walk_out, 1);
src_p = scatterwalk_whichbuf(&walk_in, bsize, tmp_src); src_p = scatterwalk_whichbuf(&walk_in, bsize, tmp_src);
dst_p = scatterwalk_whichbuf(&walk_out, bsize, tmp_dst); dst_p = scatterwalk_whichbuf(&walk_out, bsize, tmp_dst);
in_place = scatterwalk_samebuf(&walk_in, &walk_out,
src_p, dst_p);
nbytes -= bsize; nbytes -= bsize;
scatterwalk_copychunks(src_p, &walk_in, bsize, 0); scatterwalk_copychunks(src_p, &walk_in, bsize, 0);
prfn(tfm, dst_p, src_p, crfn, enc, info, prfn(tfm, dst_p, src_p, crfn, enc, info, in_place);
scatterwalk_samebuf(&walk_in, &walk_out,
src_p, dst_p));
scatterwalk_done(&walk_in, 0, nbytes); scatterwalk_done(&walk_in, 0, nbytes);
......
...@@ -38,6 +38,7 @@ static inline int scatterwalk_samebuf(struct scatter_walk *walk_in, ...@@ -38,6 +38,7 @@ static inline int scatterwalk_samebuf(struct scatter_walk *walk_in,
void *src_p, void *dst_p) void *src_p, void *dst_p)
{ {
return walk_in->page == walk_out->page && return walk_in->page == walk_out->page &&
walk_in->offset == walk_out->offset &&
walk_in->data == src_p && walk_out->data == dst_p; walk_in->data == src_p && walk_out->data == dst_p;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment