Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp927779rwj; Fri, 23 Dec 2022 09:55:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXvKSNQKUkGi+GNTLlqoGrJnGQmnm2p82Cs64AzyLpIR3UUikGNTwqVSqcUKoU4tATiX/brG X-Received: by 2002:a17:906:71b:b0:7c1:9462:2dd3 with SMTP id y27-20020a170906071b00b007c194622dd3mr8570859ejb.70.1671818113819; Fri, 23 Dec 2022 09:55:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671818113; cv=none; d=google.com; s=arc-20160816; b=DGbTeqfA04j/0ISIib8OxEizlYiZNmaxs1f9aMa4ualvBADyoTJeXSqX+HhjAuuKyj 0a0yyChKJ79dFSiIPYRLU/7e/cPBz3d/euygSk6577L8lahTji5yg0Xl7Z3xyA8sbtWQ 4tKfI4Pf1okZw5ID+jcSQ2dt4E2xx0bKYk8PvFkBBad5i6/hwOH0Xii8qBIMNTBSdOm9 suy6nli9/SnG4D15mrFQZx9eko9fPPxgm+Lu9rZrVJBWwtfKZou7LqOojJrlssITgfMZ w+DEgQPtka++0UfEyDdhg9FWEQ9vF1oTupAlUwplhrEinxejHoRCvu7RguGICyn4OpOr zGSQ== 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=IerH6ihwPTRBXlD/NKvzHJ3V3HjPKUF/eKg3jT/Pd5o=; b=aBCqsg/qUQHG6L+Ovv7YEFjmr+2C0AmJpFGx2qV8TRFKMPxZeuHlxPKcIgyb4Wpdhf VGNeIr/2aAbaJSLgKPbhChMm1AZ9WMuQJDB01iLHXi4SU9WOPA4+DxnTcVlEfuXKWDz7 Bb0fbX5/IYlxqv/JXfB6Hdhv11JmwE0umnj2QjHsO4fSx2ClWuzW4/dR/KWZLMOW8iJj MK5jpUQGqEVVi/i+B4Ochr0zHIS5v75RmPakesEtEm0hsKP9b1U1ixHhPbx243/++IYS HGZoezdrQy3iLXRWDMSn0Vp1Pkjx2brk3AkMI4e5aw8aDCpCtC4kqGUD0nmchd8RPx63 KYgA== 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 dd8-20020a1709069b8800b007ae74740fa4si3260719ejc.275.2022.12.23.09.54.45; Fri, 23 Dec 2022 09:55:13 -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 S230489AbiLWRrc (ORCPT + 99 others); Fri, 23 Dec 2022 12:47:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232313AbiLWRrc (ORCPT ); Fri, 23 Dec 2022 12:47:32 -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 5F21E1B9C0 for ; Fri, 23 Dec 2022 09:47:31 -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 1p8m8k-00035B-P9; Fri, 23 Dec 2022 18:47:26 +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 1p8m8g-001Gn7-6C; Fri, 23 Dec 2022 18:47:22 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1p8m8f-007POs-GV; Fri, 23 Dec 2022 18:47:21 +0100 Date: Fri, 23 Dec 2022 18:47:19 +0100 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Herbert Xu Cc: Horia =?utf-8?Q?Geant=C4=83?= , Gaurav Jain , Pankaj Gupta , linux-crypto@vger.kernel.org, kernel@pengutronix.de, "David S. Miller" Subject: Re: [PATCH] crypto: caam - Prevent fortify error Message-ID: <20221223174719.4n6pmwio4zycj2qm@pengutronix.de> References: <20221222162513.4021928-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="4voh3jrqjlnm7uvs" 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=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS 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: X-Mailing-List: linux-crypto@vger.kernel.org --4voh3jrqjlnm7uvs Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 23, 2022 at 02:29:52PM +0800, Herbert Xu wrote: > On Thu, Dec 22, 2022 at 05:25:13PM +0100, Uwe Kleine-K=C3=B6nig wrote: > > When compiling arm64 allmodconfig with gcc 10.2.1 I get > >=20 > > drivers/crypto/caam/desc_constr.h: In function =E2=80=98append_data.co= nstprop=E2=80=99: > > include/linux/fortify-string.h:57:29: error: argument 2 null where non= -null expected [-Werror=3Dnonnull] > >=20 > > Fix this by skipping the memcpy if data is NULL and add a BUG_ON instead > > that triggers on a problematic call that is now prevented to trigger. > > After data =3D=3D NULL && len !=3D 0 is known to be false, logically > >=20 > > if (len) > > memcpy(...) > >=20 > > could be enough to know that memcpy is not called with dest=3DNULL, but > > gcc doesn't seem smart enough for that conclusion. gcc 12 doesn't have a > > problem with the original code. > >=20 > > Signed-off-by: Uwe Kleine-K=C3=B6nig > > --- > > drivers/crypto/caam/desc_constr.h | 8 +++++++- > > 1 file changed, 7 insertions(+), 1 deletion(-) >=20 > Does this patch fix your problem? >=20 > https://lore.kernel.org/all/Y4mHjKXnF%2F4Pfw5I@gondor.apana.org.au/ Using if (data && len) fixes it (that's the patch that b4 picks for the above message id :-\), if (!IS_ENABLED(CONFIG_CRYPTO_DEV_FSL_CAAM_DEBUG) && len) makes the problem go away, too. But I wonder if the latter is correct. Shouldn't the memcpy happen even with that debugging symbol enabled? > If not please send me your kconfig file. (It's a plain arm64 allmodconfig) Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=C3=B6nig = | Industrial Linux Solutions | https://www.pengutronix.de/ | --4voh3jrqjlnm7uvs Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmOl6aQACgkQwfwUeK3K 7AmihAf9H/w2F3oDM6uvf5HktZ+6qpmKs6xTCa0tnkKBTX2Fb2zi9rHZPo2r33Cg ZjT1+f5mFfKKN2N5kfV2ibY8m85nIdWvqbrVDEDzAhLU/pWrUCVYGVLl2Voy6LPU FjGDuCo3GGCL1st84GimKp1two6RQAuRNgBzTvOSI1mJ/fZ4vNXVSZ9n7UtuEDgX cOL2YWOXm/H5/yJ36QfIJ4MqPQYLkCs6RQsVWUoC11uCqJvea8WSqA9yXw5j4AaD g99Zrj79KFeSjygfOROf4/zKCU/IAQw/qqwmGeEZuA4O2/ncq0g7dk6c7PYKvcPm zvMV1sFbSFQZZJ+lP6XyedlKJ9BC1w== =pWt7 -----END PGP SIGNATURE----- --4voh3jrqjlnm7uvs--