Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753372AbcJJRaB (ORCPT ); Mon, 10 Oct 2016 13:30:01 -0400 Received: from smtprelay0006.hostedemail.com ([216.40.44.6]:38739 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753134AbcJJRaA (ORCPT ); Mon, 10 Oct 2016 13:30:00 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:41:355:379:541:599:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1540:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:2918:3138:3139:3140:3141:3142:3352:3622:3865:3867:3870:3871:3872:4321:5007:6119:7903:10004:10400:10848:11026:11232:11658:11914:12043:12296:12438:12740:12760:13069:13311:13357:13439:14659:14721:21080:30054:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: wool44_56e714d93444a X-Filterd-Recvd-Size: 1661 Message-ID: <1476120595.2856.28.camel@perches.com> Subject: Re: [PATCH] crypto: cmac - fix alignment of 'consts' From: Joe Perches To: Eric Biggers , herbert@gondor.apana.org.au, davem@davemloft.net Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 10 Oct 2016 10:29:55 -0700 In-Reply-To: <1476119715-71397-2-git-send-email-ebiggers@google.com> References: <1476119715-71397-2-git-send-email-ebiggers@google.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.0-2ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 831 Lines: 18 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))