Message ID | ZVz8fLtrYTz+YSjn@work |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp844692vqb; Tue, 21 Nov 2023 10:53:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IHHJrOZD7JxA8vkzaYAgcyKZJ30j5XIaaENWWqh5qge8+tX+XBt8cepEMtTeif0TnpqHyYV X-Received: by 2002:a05:6808:1210:b0:3af:9330:9494 with SMTP id a16-20020a056808121000b003af93309494mr201606oil.32.1700592784515; Tue, 21 Nov 2023 10:53:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700592784; cv=none; d=google.com; s=arc-20160816; b=Cuwk2s3P6wzgBovar4UfmLO1cvw2iNq8VTeMEtd8EKuIv0UKOuyaQTF312dEmL+xYP /yPFclCLthXfMWDWLqKUx5HBrJNX6aQnpSYySebMnCXIC/PQImjqtoHvUZrV9MIF/QBm BnFlyYrUkiIC0cIQrULeIXZzltrSVrkhQsj4Y7hItdHC69ybtvVPGXYNSaj4G4MKUEhu 6bsCxXheQeSQpvP1n0DzH72BjEoR+jXUEzldSQfwdcwKapxYr1TjWjHNeAWCw9TyIYIZ ot0RHHtrwGRN9iIiLQgV5jEodD4FwWstElSEoQ1GJ42AD3XsmGnv0AgETexRLDzbl1lY Mb1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=bTx4IyrAE50Caht45+H83eCUZ/tKREgI7e2pziFI9aU=; fh=Tjfz5RQL5sHZuYmIaK3Lju4xGeIIGh4DgT/lZuqjKes=; b=bU5sFizLMRtGwb6G0Hk+8TPakz9PB1EtzPe0n4xO2d4JjjoXAh6/OGpJZEaLcBTFnS 1/Mt5oi0+OwL19Ez5aBm4cu29lWFYiQxZ0r4FjOEjRM5BRRAObLGZtWuHY1JtOhMIJKY i4Lu2nYUxnvD2RLJIbmvMKabp/J2opESCvX8IowRgrAzrfR5G19s9P8wHkzfh+LdK948 JjpDphUXeO3PMFGlMw1rmwSq5tci22P7oXKCBFZ2EwlN//LvR+vpvx4n1v1EyOxUHt2P QX+S/KP71BmNcyiHCMiaVzPJ+PmR/EvI4dlWUi381Pt5K5gj6UF9UWCxa8Vbd3wEJ28i jGeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=POVK2c2w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id w6-20020a634906000000b005c2157e8483si8886229pga.231.2023.11.21.10.53.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 10:53:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=POVK2c2w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A2C17811F123; Tue, 21 Nov 2023 10:52:56 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234391AbjKUSww (ORCPT <rfc822;ouuuleilei@gmail.com> + 99 others); Tue, 21 Nov 2023 13:52:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230492AbjKUSwv (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 21 Nov 2023 13:52:51 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04FC9B9 for <linux-kernel@vger.kernel.org>; Tue, 21 Nov 2023 10:52:48 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9422EC433C8; Tue, 21 Nov 2023 18:52:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700592767; bh=5RbPe9Jo0Kx3jw4qthF98qjBS4eZ7mQNCwFgjLRcjnI=; h=Date:From:To:Cc:Subject:From; b=POVK2c2wUB2WPyUQZ1NtanCPyJem4EWudfnE4UYZaZ0vaiCOrIS/HI8x2cXwXfwVb 0MXJ8q+hnv02iCqaJQ2ZZkkJRfA4Q6dYuo6hON2+9iCHeYTYixTHVI5eWbDKuVF/JW 41F0ZeT4rNZer1RONY+r6xxSrHp1QSPCU9ntqIptnX2hY4dAojK6ucWB1HMMb+qMpr rePbvv2uzJiY6cxlhubAa5tyRExehUcMwP/773+vC4QUvT4pB1iW5eGE6XPv2g7klm fvzObIfzE3FmkuqyX8hCfHdZmLwKsi36JJVYy8lez7sGa1w+cvvyRV+MMt+YNDgjqM xOSzs7obbDfUQ== Date: Tue, 21 Nov 2023 12:52:44 -0600 From: "Gustavo A. R. Silva" <gustavoars@kernel.org> To: Herbert Xu <herbert@gondor.apana.org.au>, "David S. Miller" <davem@davemloft.net>, Michael Ellerman <mpe@ellerman.id.au>, Nicholas Piggin <npiggin@gmail.com>, Christophe Leroy <christophe.leroy@csgroup.eu> Cc: linux-crypto@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" <gustavoars@kernel.org>, linux-hardening@vger.kernel.org Subject: [PATCH][next] powerpc/crypto: Avoid -Wstringop-overflow warnings Message-ID: <ZVz8fLtrYTz+YSjn@work> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 21 Nov 2023 10:52:56 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783200779705342405 X-GMAIL-MSGID: 1783200779705342405 |
Series |
[next] powerpc/crypto: Avoid -Wstringop-overflow warnings
|
|
Commit Message
Gustavo A. R. Silva
Nov. 21, 2023, 6:52 p.m. UTC
The compiler doesn't know that `32` is an offset into the Hash table:
56 struct Hash_ctx {
57 u8 H[16]; /* subkey */
58 u8 Htable[256]; /* Xi, Hash table(offset 32) */
59 };
So, it legitimately complains about a potential out-of-bounds issue
if `256 bytes` are accessed in `htable` (this implies going
`32 bytes` beyond the boundaries of `Htable`):
arch/powerpc/crypto/aes-gcm-p10-glue.c: In function 'gcmp10_init':
arch/powerpc/crypto/aes-gcm-p10-glue.c:120:9: error: 'gcm_init_htable' accessing 256 bytes in a region of size 224 [-Werror=stringop-overflow=]
120 | gcm_init_htable(hash->Htable+32, hash->H);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/crypto/aes-gcm-p10-glue.c:120:9: note: referencing argument 1 of type 'unsigned char[256]'
arch/powerpc/crypto/aes-gcm-p10-glue.c:120:9: note: referencing argument 2 of type 'unsigned char[16]'
arch/powerpc/crypto/aes-gcm-p10-glue.c:40:17: note: in a call to function 'gcm_init_htable'
40 | asmlinkage void gcm_init_htable(unsigned char htable[256], unsigned char Xi[16]);
| ^~~~~~~~~~~~~~~
Address this by avoiding specifying the size of `htable` in the function
prototype; and just for consistency, do the same for parameter `Xi`.
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Closes: https://lore.kernel.org/linux-next/20231121131903.68a37932@canb.auug.org.au/
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
arch/powerpc/crypto/aes-gcm-p10-glue.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Tue, Nov 21, 2023 at 12:52:44PM -0600, Gustavo A. R. Silva wrote: > The compiler doesn't know that `32` is an offset into the Hash table: > > 56 struct Hash_ctx { > 57 u8 H[16]; /* subkey */ > 58 u8 Htable[256]; /* Xi, Hash table(offset 32) */ > 59 }; > > So, it legitimately complains about a potential out-of-bounds issue > if `256 bytes` are accessed in `htable` (this implies going > `32 bytes` beyond the boundaries of `Htable`): > > arch/powerpc/crypto/aes-gcm-p10-glue.c: In function 'gcmp10_init': > arch/powerpc/crypto/aes-gcm-p10-glue.c:120:9: error: 'gcm_init_htable' accessing 256 bytes in a region of size 224 [-Werror=stringop-overflow=] > 120 | gcm_init_htable(hash->Htable+32, hash->H); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > arch/powerpc/crypto/aes-gcm-p10-glue.c:120:9: note: referencing argument 1 of type 'unsigned char[256]' > arch/powerpc/crypto/aes-gcm-p10-glue.c:120:9: note: referencing argument 2 of type 'unsigned char[16]' > arch/powerpc/crypto/aes-gcm-p10-glue.c:40:17: note: in a call to function 'gcm_init_htable' > 40 | asmlinkage void gcm_init_htable(unsigned char htable[256], unsigned char Xi[16]); > | ^~~~~~~~~~~~~~~ > > Address this by avoiding specifying the size of `htable` in the function > prototype; and just for consistency, do the same for parameter `Xi`. > > Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> > Closes: https://lore.kernel.org/linux-next/20231121131903.68a37932@canb.auug.org.au/ > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> > --- > arch/powerpc/crypto/aes-gcm-p10-glue.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Patch applied. Thanks.
diff --git a/arch/powerpc/crypto/aes-gcm-p10-glue.c b/arch/powerpc/crypto/aes-gcm-p10-glue.c index 4b6e899895e7..f62ee54076c0 100644 --- a/arch/powerpc/crypto/aes-gcm-p10-glue.c +++ b/arch/powerpc/crypto/aes-gcm-p10-glue.c @@ -37,7 +37,7 @@ asmlinkage void aes_p10_gcm_encrypt(u8 *in, u8 *out, size_t len, void *rkey, u8 *iv, void *Xi); asmlinkage void aes_p10_gcm_decrypt(u8 *in, u8 *out, size_t len, void *rkey, u8 *iv, void *Xi); -asmlinkage void gcm_init_htable(unsigned char htable[256], unsigned char Xi[16]); +asmlinkage void gcm_init_htable(unsigned char htable[], unsigned char Xi[]); asmlinkage void gcm_ghash_p10(unsigned char *Xi, unsigned char *Htable, unsigned char *aad, unsigned int alen);