Message ID | 20230523083313.899332-1-arnd@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1991907vqo; Tue, 23 May 2023 01:56:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ664hQj9nE0BDY5SE5kVqs7daiZD2tufAsiHUzf+qlIsa0suI7aAozM+aEdoEs4awqEauuq X-Received: by 2002:a17:902:c945:b0:1a9:546c:1593 with SMTP id i5-20020a170902c94500b001a9546c1593mr17406795pla.14.1684832218492; Tue, 23 May 2023 01:56:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684832218; cv=none; d=google.com; s=arc-20160816; b=hMJuQYPZFopf5a7K9VgjpCqA2rPev700sFUcfYXTpQ2agsXMoG20NR7jefFVjk9ENp ACZWl9lqIoc/fyMz4MRqrxVlmO4WJ+kmrufVupKTKyJzOdVphA5t4hXelUJ2Bg1SdvSu sqI22X16P+2OC0SenGLK59+zVnIXD1juZWeqiQm4F+3eQCaE711YOLoDWiNrDaHA49La TAPY06j5m3BVKH/8wrlZlnFonZDf87WlzvYP/TI7qvZSE3uGLY9AlRihVJpWTPb1Zqdn kWN8VchHmNO2Z1PcK3Imog7b6Jx8M0MGQLWfdJ0zp26C3QSETUXLgPbrr6LxzUppEnko ijbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Tjygt2kF3vcabYBl3p6zKHVU3+z2uiwHg81/whO6Nks=; b=KQvZZdfqLLtPtfHBquD2XO3K7V2vB9g0wSMvUy40/8GgVBFYUgaq6VaBfI58P23Zkj hKL4joyswo0HEN/NR3z/OdvCj6xS+VCnfQbjq5jy4/V/eujXeGmZJYadIaoCpn0UP0do glhNMk3vZZTlornlADRi1hGhjo4YyxtmjeaoMWKKfnpoQrOm3I23yO8i39YRP2T4yNum pimEW9R5jUcS8tz0KhhmkR07Ohm2yI6WRY5fuosyQ31ULfQy6qFUr3CRws4mrs8gaxCM MJjW+DBy/gzwHEOUuInBQ6Jqt5n/pr4HGdD8MDSVcjGFYWdaZf2YsnpofTs/Rsrzmpx9 4O5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VjlerZ6D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id iz12-20020a170902ef8c00b001adcdac8969si5841204plb.463.2023.05.23.01.56.43; Tue, 23 May 2023 01:56:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VjlerZ6D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235614AbjEWIfh (ORCPT <rfc822;ahmedalshaiji.dev@gmail.com> + 99 others); Tue, 23 May 2023 04:35:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236217AbjEWIfA (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 23 May 2023 04:35:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 314FA10EF; Tue, 23 May 2023 01:33:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8C2B5601C6; Tue, 23 May 2023 08:33:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE65AC4339B; Tue, 23 May 2023 08:33:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684830800; bh=MnGHsJX536Td4nzr8n47Z1xXn9aYKRj+yG30BHNM0pE=; h=From:To:Cc:Subject:Date:From; b=VjlerZ6DwRlft+MW5AKa+6QzLwoGVwrBuYKV+9G06XcHljxy7GOaXAbhHxd9ty586 UWdkKzXGJtP3kRTiZHA09Hl2Pl0CNxAEpvuTodMwV/nnbjo2sWcEn+ndrB3DH/CISL cbVi/qZnNhjVc/KZgj9Azp3zgVlNZ+MUjvA22O5mbEPUi1vVVMnr0hjai3o7mATxzU Tzc2RVu1t0N9TguAkJhw9vR6d9p2E+HZjl85aDIVRq6XwxHCF6ramLRYPb64N7GQol qj9Ri9a+fbbIWlle9CCv5FzqeUWcqSCPNk7HEyFIdhmKOUcnbA9a7DbJJvvrZYpVHO R/I8YD1ENffig== From: Arnd Bergmann <arnd@kernel.org> To: Boris Brezillon <bbrezillon@kernel.org>, Arnaud Ebalard <arno@natisbad.org>, Srujana Challa <schalla@marvell.com>, Herbert Xu <herbert@gondor.apana.org.au>, "David S. Miller" <davem@davemloft.net> Cc: Arnd Bergmann <arnd@arndb.de>, Kees Cook <keescook@chromium.org>, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] crypto: marvell/cesa - Fix type mismatch warning Date: Tue, 23 May 2023 10:33:04 +0200 Message-Id: <20230523083313.899332-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766674628279040817?= X-GMAIL-MSGID: =?utf-8?q?1766674628279040817?= |
Series |
crypto: marvell/cesa - Fix type mismatch warning
|
|
Commit Message
Arnd Bergmann
May 23, 2023, 8:33 a.m. UTC
From: Arnd Bergmann <arnd@arndb.de> Commit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3") uncovered a type mismatch in cesa 3des support that leads to a memcpy beyond the end of a structure: In function 'fortify_memcpy_chk', inlined from 'mv_cesa_des3_ede_setkey' at drivers/crypto/marvell/cesa/cipher.c:307:2: include/linux/fortify-string.h:583:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning] 583 | __write_overflow_field(p_size_field, size); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is probably harmless as the actual data that is copied has the correct type, but clearly worth fixing nonetheless. Fixes: 4ada48397823 ("crypto: marvell/cesa - add Triple-DES support") Cc: Kees Cook <keescook@chromium.org> Cc: Gustavo A. R. Silva" <gustavoars@kernel.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/crypto/marvell/cesa/cipher.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Tue, May 23, 2023 at 10:33:04AM +0200, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > Commit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3") uncovered > a type mismatch in cesa 3des support that leads to a memcpy beyond the > end of a structure: > > In function 'fortify_memcpy_chk', > inlined from 'mv_cesa_des3_ede_setkey' at drivers/crypto/marvell/cesa/cipher.c:307:2: > include/linux/fortify-string.h:583:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning] > 583 | __write_overflow_field(p_size_field, size); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > This is probably harmless as the actual data that is copied has the correct > type, but clearly worth fixing nonetheless. > > Fixes: 4ada48397823 ("crypto: marvell/cesa - add Triple-DES support") > Cc: Kees Cook <keescook@chromium.org> > Cc: Gustavo A. R. Silva" <gustavoars@kernel.org> > Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Kees Cook <keescook@chromium.org>
On Tue, 23 May 2023 10:33:04 +0200, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > Commit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3") uncovered > a type mismatch in cesa 3des support that leads to a memcpy beyond the > end of a structure: > > In function 'fortify_memcpy_chk', > inlined from 'mv_cesa_des3_ede_setkey' at drivers/crypto/marvell/cesa/cipher.c:307:2: > include/linux/fortify-string.h:583:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning] > 583 | __write_overflow_field(p_size_field, size); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > [...] Applied to for-next/hardening, thanks! [1/1] crypto: marvell/cesa - Fix type mismatch warning https://git.kernel.org/kees/c/37f3abddda8d
On Tue, May 30, 2023 at 03:48:49PM -0700, Kees Cook wrote: > On Tue, 23 May 2023 10:33:04 +0200, Arnd Bergmann wrote: > > From: Arnd Bergmann <arnd@arndb.de> > > > > Commit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3") uncovered > > a type mismatch in cesa 3des support that leads to a memcpy beyond the > > end of a structure: > > > > In function 'fortify_memcpy_chk', > > inlined from 'mv_cesa_des3_ede_setkey' at drivers/crypto/marvell/cesa/cipher.c:307:2: > > include/linux/fortify-string.h:583:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning] > > 583 | __write_overflow_field(p_size_field, size); > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > [...] > > Applied to for-next/hardening, thanks! > > [1/1] crypto: marvell/cesa - Fix type mismatch warning > https://git.kernel.org/kees/c/37f3abddda8d Why did you apply it to your tree? This patch makes sense on its own regardless of the fortify changes. Thanks,
On Wed, May 31, 2023 at 06:58:10PM +0800, Herbert Xu wrote: > On Tue, May 30, 2023 at 03:48:49PM -0700, Kees Cook wrote: > > On Tue, 23 May 2023 10:33:04 +0200, Arnd Bergmann wrote: > > > From: Arnd Bergmann <arnd@arndb.de> > > > > > > Commit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3") uncovered > > > a type mismatch in cesa 3des support that leads to a memcpy beyond the > > > end of a structure: > > > > > > In function 'fortify_memcpy_chk', > > > inlined from 'mv_cesa_des3_ede_setkey' at drivers/crypto/marvell/cesa/cipher.c:307:2: > > > include/linux/fortify-string.h:583:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning] > > > 583 | __write_overflow_field(p_size_field, size); > > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > > > [...] > > > > Applied to for-next/hardening, thanks! > > > > [1/1] crypto: marvell/cesa - Fix type mismatch warning > > https://git.kernel.org/kees/c/37f3abddda8d > > Why did you apply it to your tree? This patch makes sense on its > own regardless of the fortify changes. I snagged it since a week had gone by with no additional discussion and it fixed an issue exposed by work in the hardening tree. Let me know if you'd prefer I drop it for you to carry instead. -Kees
On Wed, May 31, 2023 at 09:31:18AM -0700, Kees Cook wrote: . > I snagged it since a week had gone by with no additional discussion and > it fixed an issue exposed by work in the hardening tree. Let me know if > you'd prefer I drop it for you to carry instead. Yes because these sort of changes cause unnecessary conflicts. It's not as if the patch depends on something in the hardening tree. Thanks,
On Thu, Jun 01, 2023 at 06:18:37PM +0800, Herbert Xu wrote: > On Wed, May 31, 2023 at 09:31:18AM -0700, Kees Cook wrote: > . > > I snagged it since a week had gone by with no additional discussion and > > it fixed an issue exposed by work in the hardening tree. Let me know if > > you'd prefer I drop it for you to carry instead. > > Yes because these sort of changes cause unnecessary conflicts. > It's not as if the patch depends on something in the hardening > tree. Done! :)
On Tue, May 23, 2023 at 10:33:04AM +0200, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > Commit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3") uncovered > a type mismatch in cesa 3des support that leads to a memcpy beyond the > end of a structure: > > In function 'fortify_memcpy_chk', > inlined from 'mv_cesa_des3_ede_setkey' at drivers/crypto/marvell/cesa/cipher.c:307:2: > include/linux/fortify-string.h:583:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning] > 583 | __write_overflow_field(p_size_field, size); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > This is probably harmless as the actual data that is copied has the correct > type, but clearly worth fixing nonetheless. > > Fixes: 4ada48397823 ("crypto: marvell/cesa - add Triple-DES support") > Cc: Kees Cook <keescook@chromium.org> > Cc: Gustavo A. R. Silva" <gustavoars@kernel.org> > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > --- > drivers/crypto/marvell/cesa/cipher.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Patch applied. Thanks.
diff --git a/drivers/crypto/marvell/cesa/cipher.c b/drivers/crypto/marvell/cesa/cipher.c index c6f2fa753b7c..0f37dfd42d85 100644 --- a/drivers/crypto/marvell/cesa/cipher.c +++ b/drivers/crypto/marvell/cesa/cipher.c @@ -297,7 +297,7 @@ static int mv_cesa_des_setkey(struct crypto_skcipher *cipher, const u8 *key, static int mv_cesa_des3_ede_setkey(struct crypto_skcipher *cipher, const u8 *key, unsigned int len) { - struct mv_cesa_des_ctx *ctx = crypto_skcipher_ctx(cipher); + struct mv_cesa_des3_ctx *ctx = crypto_skcipher_ctx(cipher); int err; err = verify_skcipher_des3_key(cipher, key);