From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4308FC3DA7C for ; Wed, 28 Dec 2022 11:30:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229966AbiL1Lau (ORCPT ); Wed, 28 Dec 2022 06:30:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229864AbiL1Laq (ORCPT ); Wed, 28 Dec 2022 06:30:46 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E4571CB for ; Wed, 28 Dec 2022 03:30:45 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pAUds-0005GS-FN; Wed, 28 Dec 2022 12:30:40 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pAUdq-002GsG-AY; Wed, 28 Dec 2022 12:30:38 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pAUdp-008VoX-Hg; Wed, 28 Dec 2022 12:30:37 +0100 Date: Wed, 28 Dec 2022 12:30:35 +0100 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Herbert Xu Cc: Anders Roxell , Kees Cook , Horia =?utf-8?Q?Geant=C4=83?= , Gaurav Jain , Pankaj Gupta , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, linux-crypto@vger.kernel.org, kernel@pengutronix.de, "David S. Miller" , kernel test robot Subject: Re: [PATCH] crypto: caam - Avoid GCC memset bug warning Message-ID: <20221228113035.ups6echnsmo4flnz@pengutronix.de> References: <20221222162513.4021928-1-u.kleine-koenig@pengutronix.de> <20221223174719.4n6pmwio4zycj2qm@pengutronix.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="gaxrg6dgi72ticld" Content-Disposition: inline In-Reply-To: X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --gaxrg6dgi72ticld Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Dec 28, 2022 at 04:46:39PM +0800, Herbert Xu wrote: > Certain versions of gcc don't like the memcpy with a NULL dst > (which only happens with a zero length). This only happens > when debugging is enabled so add an if clause to work around > these warnings. >=20 > A similar warning used to be generated by sparse but that was > fixed years ago. >=20 > Link: https://lore.kernel.org/lkml/202210290446.qBayTfzl-lkp@intel.com > Reported-by: kernel test robot > Reported-by: Kees Cook > Reported-by: Uwe Kleine-K=EF=BF=BDnig > Signed-off-by: Herbert Xu >=20 > diff --git a/drivers/crypto/caam/desc_constr.h b/drivers/crypto/caam/desc= _constr.h > index 62ce6421bb3f..824c94d44f94 100644 > --- a/drivers/crypto/caam/desc_constr.h > +++ b/drivers/crypto/caam/desc_constr.h > @@ -163,7 +163,8 @@ static inline void append_data(u32 * const desc, cons= t void *data, int len) > { > u32 *offset =3D desc_end(desc); > =20 > - if (len) /* avoid sparse warning: memcpy with byte count of 0 */ > + /* Avoid gcc warning: memcpy with data =3D=3D NULL */ > + if (!IS_ENABLED(CONFIG_CRYPTO_DEV_FSL_CAAM_DEBUG) || data) I just tried: For me a plain if (data) is also enough to make both gcc and sparse happy. (On a related note, sparse reports: CHECK drivers/crypto/caam/jr.c drivers/crypto/caam/jr.c: note: in included file (through arch/arm64/includ= e/asm/io.h, include/linux/io.h, include/linux/irq.h, ...): include/asm-generic/io.h:290:22: warning: incorrect type in argument 1 (dif= ferent base types) include/asm-generic/io.h:290:22: expected unsigned long long [usertype] = val include/asm-generic/io.h:290:22: got restricted __le64 [usertype] include/asm-generic/io.h:290:22: warning: incorrect type in argument 1 (dif= ferent base types) include/asm-generic/io.h:290:22: expected unsigned long long [usertype] = val include/asm-generic/io.h:290:22: got restricted __le64 [usertype] Didn't look into that though.) Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=C3=B6nig = | Industrial Linux Solutions | https://www.pengutronix.de/ | --gaxrg6dgi72ticld Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmOsKNkACgkQwfwUeK3K 7AmDTwf+IuUVfMjDYicgKbEIu+CX1FN2NZUUW5qaon/vZyXKji1o2grwEzVYRPwE m/pm8APNaT/2BlmiN8C0a4Ax/yXjfrzQnClMXxa96Tl5cMsf4AD5wEM6aFdxFUct td471SO3y13UtPvSl01Q9pcv4E2RLxyt1g4hlXEbM7hNnZhBYA1nFlqPIyqf8lB+ H09vp5Ik6Vclv7PfDiprlMLWSwzh8NLWpYpYCDlNVgwjAizzVI17OyD1fWH/sYaj WOUoONKLJgsITZnZ2k7SWww+RuAbZCAmxKjO7vJVukgHg+P5JWjzEsxYl1MRqdoN +b/sP7duuBP57MFlQJQnGXft8SuSNw== =gV7e -----END PGP SIGNATURE----- --gaxrg6dgi72ticld--