* [PATCH] crypto: xcbc - Fix alignment calculation of xcbc_tfm_ctx
@ 2009-08-19 7:09 Steffen Klassert
2009-08-20 7:59 ` Herbert Xu
0 siblings, 1 reply; 2+ messages in thread
From: Steffen Klassert @ 2009-08-19 7:09 UTC (permalink / raw)
To: Herbert Xu; +Cc: linux-crypto
The alignment calculation of xcbc_tfm_ctx uses alg->cra_alignmask
and not alg->cra_alignmask + 1 as it should. This led to frequent
crashes during the selftest of xcbc(aes-asm) on x86_64
machines. This patch fixes this. Also we use the alignmask
of xcbc and not the alignmask of the underlying algorithm
for the alignmnent calculation in xcbc_create now.
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
crypto/xcbc.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/crypto/xcbc.c b/crypto/xcbc.c
index 1e30b31..bb7b67f 100644
--- a/crypto/xcbc.c
+++ b/crypto/xcbc.c
@@ -199,6 +199,7 @@ static int xcbc_create(struct crypto_template *tmpl, struct rtattr **tb)
{
struct shash_instance *inst;
struct crypto_alg *alg;
+ unsigned long alignmask;
int err;
err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_SHASH);
@@ -228,19 +229,20 @@ static int xcbc_create(struct crypto_template *tmpl, struct rtattr **tb)
if (err)
goto out_free_inst;
+ alignmask = alg->cra_alignmask | 3;
+ inst->alg.base.cra_alignmask = alignmask;
inst->alg.base.cra_priority = alg->cra_priority;
inst->alg.base.cra_blocksize = alg->cra_blocksize;
- inst->alg.base.cra_alignmask = alg->cra_alignmask | 3;
inst->alg.digestsize = alg->cra_blocksize;
inst->alg.descsize = ALIGN(sizeof(struct xcbc_desc_ctx),
crypto_tfm_ctx_alignment()) +
- (alg->cra_alignmask &
+ (alignmask &
~(crypto_tfm_ctx_alignment() - 1)) +
alg->cra_blocksize * 2;
inst->alg.base.cra_ctxsize = ALIGN(sizeof(struct xcbc_tfm_ctx),
- alg->cra_alignmask) +
+ alignmask + 1) +
alg->cra_blocksize * 2;
inst->alg.base.cra_init = xcbc_init_tfm;
inst->alg.base.cra_exit = xcbc_exit_tfm;
--
1.5.4.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] crypto: xcbc - Fix alignment calculation of xcbc_tfm_ctx
2009-08-19 7:09 [PATCH] crypto: xcbc - Fix alignment calculation of xcbc_tfm_ctx Steffen Klassert
@ 2009-08-20 7:59 ` Herbert Xu
0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2009-08-20 7:59 UTC (permalink / raw)
To: Steffen Klassert; +Cc: linux-crypto
On Wed, Aug 19, 2009 at 09:09:02AM +0200, Steffen Klassert wrote:
> The alignment calculation of xcbc_tfm_ctx uses alg->cra_alignmask
> and not alg->cra_alignmask + 1 as it should. This led to frequent
> crashes during the selftest of xcbc(aes-asm) on x86_64
> machines. This patch fixes this. Also we use the alignmask
> of xcbc and not the alignmask of the underlying algorithm
> for the alignmnent calculation in xcbc_create now.
>
> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Good catch!
I wonder why I didn't see it though as I too was testing this on
x86-64. Must've been luck I suppose as it depends on what follows
the context in memory. Anyway, patch applied to cryptodev-2.6.
Thanks,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <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:[~2009-08-20 7:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-19 7:09 [PATCH] crypto: xcbc - Fix alignment calculation of xcbc_tfm_ctx Steffen Klassert
2009-08-20 7:59 ` Herbert Xu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.