diff options
author | Horia Geantă <horia.geanta@nxp.com> | 2020-03-23 11:37:11 +0200 |
---|---|---|
committer | Dong Aisheng <aisheng.dong@nxp.com> | 2021-11-02 20:28:23 +0800 |
commit | 5c44806f76461c610fa9c90769b62499bc822be9 (patch) | |
tree | ca1baab4b70c63ef200591de5e00c89e4f47dcd3 /crypto | |
parent | d75c2ec02e0f8fe4dd3086b380def44cfbba127e (diff) |
LF-286 crypto: tcrypt - workaround for overlapping src, dst AAD
This is a temporary workround for the case when:
-SWIOTLB is used for DMA bounce buffering AND
-data to be DMA-ed is mapped DMA_FROM_DEVICE and device only partially
overwrites the "original" data AND
-it's expected that the "original" data that was not overwritten
by the device to be untouched
As discussed in upstream, the proper fix should be:
-either an extension of the DMA API OR
-a workaround in the device driver (considering these cases are rarely
met in practice)
Since both alternatives are not trivial (to say the least),
add a workaround for the few cases matching the error conditions
listed above.
Link: https://lore.kernel.org/lkml/VI1PR0402MB348537CB86926B3E6D1DBE0A98070@VI1PR0402MB3485.eurprd04.prod.outlook.com/
Link: https://lore.kernel.org/lkml/20190522072018.10660-1-horia.geanta@nxp.com/
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
Reviewed-by: Valentin Ciocoi Radulescu <valentin.ciocoi@nxp.com>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/tcrypt.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index f0fe42bebc2a..a200071fea5c 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c @@ -259,7 +259,7 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs, const int *b_size; const char *key; const char *e; - void *assoc; + void *assoc, *assoc_out; char *iv; int ret; @@ -385,6 +385,8 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs, assoc = cur->axbuf[0]; memset(assoc, 0xff, aad_size); + assoc_out = cur->axbuf[1]; + memset(assoc_out, 0xff, aad_size); sg_init_aead(cur->sg, cur->xbuf, bs + (enc ? 0 : authsize), @@ -392,7 +394,7 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs, sg_init_aead(cur->sgout, cur->xoutbuf, bs + (enc ? authsize : 0), - assoc, aad_size); + assoc_out, aad_size); aead_request_set_ad(cur->req, aad_size); @@ -410,6 +412,9 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs, ret); break; } + + memset(assoc, 0xff, aad_size); + memset(assoc_out, 0xff, aad_size); } aead_request_set_crypt(cur->req, cur->sg, @@ -536,7 +541,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, struct scatterlist *sg; struct scatterlist *sgout; const char *e; - void *assoc; + void *assoc, *assoc_out; char *iv; char *xbuf[XBUFSIZE]; char *xoutbuf[XBUFSIZE]; @@ -607,6 +612,8 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, assoc = axbuf[0]; memset(assoc, 0xff, aad_size); + assoc_out = axbuf[1]; + memset(assoc_out, 0xff, aad_size); if ((*keysize + bs) > TVMEMSIZE * PAGE_SIZE) { pr_err("template (%u) too big for tvmem (%lu)\n", @@ -644,7 +651,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, assoc, aad_size); sg_init_aead(sgout, xoutbuf, - bs + (enc ? authsize : 0), assoc, + bs + (enc ? authsize : 0), assoc_out, aad_size); aead_request_set_ad(req, aad_size); @@ -666,6 +673,9 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, ret); break; } + + memset(assoc, 0xff, aad_size); + memset(assoc_out, 0xff, aad_size); } aead_request_set_crypt(req, sg, sgout, |