summaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorArd Biesheuvel <ardb@kernel.org>2020-07-21 09:05:54 +0300
committerHerbert Xu <herbert@gondor.apana.org.au>2020-07-31 18:09:00 +1000
commit18614fdea411d506ee302d4f16adcc095f0246cd (patch)
treece874637cd6e5e2df78f925bb9d2954c3b3a9b49 /crypto
parent2fa0b79ccce0650cb17cb6ceeaa4137b47468ec1 (diff)
downloadlinux-crypto-18614fdea411d506ee302d4f16adcc095f0246cd.tar.gz
linux-crypto-18614fdea411d506ee302d4f16adcc095f0246cd.zip
crypto: xts - Replace memcpy() invocation with simple assignment
Colin reports that the memcpy() call in xts_cts_final() trigggers a "Overlapping buffer in memory copy" warning in Coverity, which is a false postive, given that tail is guaranteed to be smaller than or equal to the distance between source and destination. However, given that any additional bytes that we copy will be ignored anyway, we can simply copy XTS_BLOCK_SIZE unconditionally, which means we can use struct assignment of the array members instead, which is likely to be more efficient as well. Addresses-Coverity: ("Overlapping buffer in memory copy") Fixes: 8118cd4cf772 ("crypto: xts - add support for ciphertext stealing") Reported-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/xts.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/crypto/xts.c b/crypto/xts.c
index 3c3ed02c..ad45b009 100644
--- a/crypto/xts.c
+++ b/crypto/xts.c
@@ -171,7 +171,7 @@ static int xts_cts_final(struct skcipher_request *req,
offset - XTS_BLOCK_SIZE);
scatterwalk_map_and_copy(b, rctx->tail, 0, XTS_BLOCK_SIZE, 0);
- memcpy(b + 1, b, tail);
+ b[1] = b[0];
scatterwalk_map_and_copy(b, req->src, offset, tail, 0);
le128_xor(b, &rctx->t, b);