Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp4407524rwl; Wed, 28 Dec 2022 03:49:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXtwIFBW9mk1AYWg3j9UMvLP5VyyrFIhHie0I/ZytO15Oupi2BAJSm0GeHnLjJbwCcNWM/rx X-Received: by 2002:a17:902:a70c:b0:187:1b7a:6930 with SMTP id w12-20020a170902a70c00b001871b7a6930mr25445175plq.6.1672228178590; Wed, 28 Dec 2022 03:49:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672228178; cv=none; d=google.com; s=arc-20160816; b=yY67qOrN+ZdiX+//57a7HzxqPf1Z5TN3c00Ka/7t8CijyP9ZvyDYEGK8V2d9vTIB7a SyvWdq3fFURroZ10VIrS2efaHU7vwZXz5wH1WhGt8TW9UrhJl1mq60HNdVrbEFACnA06 zxdL+cfNzYU19WE7kGDckc0u4oH/0r1g05CwUJEGaVSlMuEX4fy3VfXZM5b6wWEKj7Qk N5+ZcmGimwRIiJUJ4d3diMOomGjxPy56TaO7exadnnPFc3tEQmTeb9dYyeHpkvxAmMPM N2EsZ4Md9fKdSy0ws3ytCxfpr+GnP96oeoFGFuqDhvxQgMUePcPId0JpYvwK3ytJphkI TX/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=9LFSVtPgNqrq5WvO9jKrCBdy1r9swWmx2gzgvFqoNqY=; b=LXckTm+nBGl/h72mVkmlkppVi3qEMVvfNWjnE7VxE9EA5esLVfKONentBJAucFvutE NcTw6QNRerrlgNuw886Jhi1mVKnPgaYnPW9Y7NaMNagIbh2Aoa9DR55biUsHToyiwZCg QuW9mN7/QAdR6hiQBs8h4OD+M8+MeTJFYKBdCjL2pvO99odzFDOyN8ZJDC6IrecgDN+s cE/aITlcrg1lE4CRmut+u/i7xSOThMe9NNmbJPS5DOuW9uvahO/Mfskym7+gGWQDrbzm bxi3LHgpzgn4n/4Of6ngE2P78zWoPEQWg4uq4mVk5g7hPbM36N5ldFCOxi5qe1THOmSq iiDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s18-20020a634512000000b0048118aa6359si16948184pga.309.2022.12.28.03.49.17; Wed, 28 Dec 2022 03:49:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-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; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232644AbiL1Lau (ORCPT + 99 others); Wed, 28 Dec 2022 06:30:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232747AbiL1Lat (ORCPT ); Wed, 28 Dec 2022 06:30:49 -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 DDB4B2A5 for ; Wed, 28 Dec 2022 03:30:47 -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-crypto@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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: X-Mailing-List: linux-crypto@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--