Skip to contentSkip to conversation

crypto: lrw - use correct alignmask

PATCH In review Eric Biggers 2 participants 2 messages May 30, 2019 – Jun 6, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: lrw - use correct alignmask

From: Eric Biggers <[email protected]>

Commit c778f96bf347 ("crypto: lrw - Optimize tweak computation") incorrectly reduced the alignmask of LRW instances from '__alignof__(u64) - 1' to '__alignof__(__be32) - 1'.

However, xor_tweak() and setkey() assume that the data and key, respectively, are aligned to 'be128', which has u64 alignment.

Fix the alignmask to be at least '__alignof__(be128) - 1'.

Fixes c778f96bf347 ("crypto: lrw - Optimize tweak computation")
Cc <[email protected]> # v4.20+
Cc Ondrej Mosnacek <[email protected]>
---
 crypto/lrw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/lrw.c +1 -1
index fa302f3f161e0..b43ea285b8c79 100644
@@ -388,7 +388,7 @@ static int create(struct crypto_template *tmpl, struct rtattr **tb)
 	inst->alg.base.cra_priority = alg->base.cra_priority;
 	inst->alg.base.cra_blocksize = LRW_BLOCK_SIZE;
 	inst->alg.base.cra_alignmask = alg->base.cra_alignmask |
-				       (__alignof__(__be32) - 1);
+				       (__alignof__(be128) - 1);
 
 	inst->alg.ivsize = LRW_BLOCK_SIZE;
 	inst->alg.min_keysize = crypto_skcipher_alg_min_keysize(alg) +
Signature · 1 line
2.22.0.rc1.257.g3120a18244-goog
maintainer
#1 lore raw
Quoted 11 lines · Eric Biggers

From: Eric Biggers <[email protected]>

Commit c778f96bf347 ("crypto: lrw - Optimize tweak computation") incorrectly reduced the alignmask of LRW instances from '__alignof__(u64) - 1' to '__alignof__(__be32) - 1'.

However, xor_tweak() and setkey() assume that the data and key, respectively, are aligned to 'be128', which has u64 alignment.

Fix the alignmask to be at least '__alignof__(be128) - 1'.

Quoted 7 lines
Fixes c778f96bf347 ("crypto: lrw - Optimize tweak computation")
Cc <[email protected]> # v4.20+
Cc Ondrej Mosnacek <[email protected]>
---
 crypto/lrw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt