All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Eric Biggers <ebiggers@google.com>,
	herbert@gondor.apana.org.au, davem@davemloft.net
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] crypto: cmac - fix alignment of 'consts'
Date: Mon, 10 Oct 2016 10:29:55 -0700	[thread overview]
Message-ID: <1476120595.2856.28.camel@perches.com> (raw)
In-Reply-To: <1476119715-71397-2-git-send-email-ebiggers@google.com>

On Mon, 2016-10-10 at 10:15 -0700, Eric Biggers wrote:
> The per-transform 'consts' array is accessed as __be64 in
> crypto_cmac_digest_setkey() but was only guaranteed to be aligned to
> __alignof__(long).  Fix this by aligning it to __alignof__(__be64).
[]
> diff --git a/crypto/cmac.c b/crypto/cmac.c
[]
> @@ -57,7 +57,8 @@ static int crypto_cmac_digest_setkey(struct crypto_shash *parent,
>  	unsigned long alignmask = crypto_shash_alignmask(parent);
>  	struct cmac_tfm_ctx *ctx = crypto_shash_ctx(parent);
>  	unsigned int bs = crypto_shash_blocksize(parent);
> -	__be64 *consts = PTR_ALIGN((void *)ctx->ctx, alignmask + 1);
> +	__be64 *consts = PTR_ALIGN((void *)ctx->ctx,
> +				   (alignmask | (__alignof__(__be64) - 1)) + 1);

Using a bitwise or looks very odd there.  Perhaps:

		min(alignmask + 1, __alignof__(__be64))

  reply	other threads:[~2016-10-10 17:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-10 17:15 [PATCH] crypto: cmac - fix alignment of 'consts' Eric Biggers
2016-10-10 17:29 ` Joe Perches [this message]
2016-10-10 17:37   ` Eric Biggers
2016-10-10 17:51     ` Joe Perches
2016-10-10 18:07       ` Eric Biggers
2016-10-21  3:15 ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1476120595.2856.28.camel@perches.com \
    --to=joe@perches.com \
    --cc=davem@davemloft.net \
    --cc=ebiggers@google.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.