linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto: lrw - use correct alignmask
@ 2019-05-30 17:53 Eric Biggers
  2019-06-06  6:53 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Biggers @ 2019-05-30 17:53 UTC (permalink / raw)
  To: linux-crypto; +Cc: linux-arm-kernel, stable, Ondrej Mosnacek

From: Eric Biggers <ebiggers@google.com>

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: <stable@vger.kernel.org> # v4.20+
Cc: Ondrej Mosnacek <omosnace@redhat.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 crypto/lrw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crypto/lrw.c b/crypto/lrw.c
index fa302f3f161e0..b43ea285b8c79 100644
--- a/crypto/lrw.c
+++ b/crypto/lrw.c
@@ -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) +
-- 
2.22.0.rc1.257.g3120a18244-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] crypto: lrw - use correct alignmask
  2019-05-30 17:53 [PATCH] crypto: lrw - use correct alignmask Eric Biggers
@ 2019-06-06  6:53 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2019-06-06  6:53 UTC (permalink / raw)
  To: Eric Biggers; +Cc: linux-crypto, linux-arm-kernel, stable, Ondrej Mosnacek

On Thu, May 30, 2019 at 10:53:08AM -0700, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> 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: <stable@vger.kernel.org> # v4.20+
> Cc: Ondrej Mosnacek <omosnace@redhat.com>
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
>  crypto/lrw.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-06-06  6:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-30 17:53 [PATCH] crypto: lrw - use correct alignmask Eric Biggers
2019-06-06  6:53 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).