Skip to content

Commit a312e07

Browse files
ebiggersherbertx
authored andcommitted
crypto: adiantum - flush destination page before unmapping
Upon additional review, the new fast path in adiantum_finish() is missing the call to flush_dcache_page() that scatterwalk_map_and_copy() was doing. It's apparently debatable whether flush_dcache_page() is actually needed, as per the discussion at https://lore.kernel.org/lkml/[email protected]/T/#u. However, it appears that currently all the helper functions that write to a page, such as scatterwalk_map_and_copy(), memcpy_to_page(), and memzero_page(), do the dcache flush. So do it to be consistent. Fixes: dadf5e5 ("crypto: adiantum - add fast path for single-page messages") Signed-off-by: Eric Biggers <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent b030c45 commit a312e07

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

crypto/adiantum.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ static int adiantum_finish(struct skcipher_request *req)
300300
le128_sub(&rctx->rbuf.bignum, &rctx->rbuf.bignum, &rctx->header_hash);
301301
if (dst_nents == 1 && dst->offset + req->cryptlen <= PAGE_SIZE) {
302302
/* Fast path for single-page destination */
303-
void *virt = kmap_local_page(sg_page(dst)) + dst->offset;
303+
struct page *page = sg_page(dst);
304+
void *virt = kmap_local_page(page) + dst->offset;
304305

305306
err = crypto_shash_digest(&rctx->u.hash_desc, virt, bulk_len,
306307
(u8 *)&digest);
@@ -310,6 +311,7 @@ static int adiantum_finish(struct skcipher_request *req)
310311
}
311312
le128_sub(&rctx->rbuf.bignum, &rctx->rbuf.bignum, &digest);
312313
memcpy(virt + bulk_len, &rctx->rbuf.bignum, sizeof(le128));
314+
flush_dcache_page(page);
313315
kunmap_local(virt);
314316
} else {
315317
/* Slow path that works for any destination scatterlist */

0 commit comments

Comments
 (0)