From patchwork Wed Dec 28 11:03:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 13082855 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 1868BC4332F for ; Wed, 28 Dec 2022 11:04:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232635AbiL1LEK (ORCPT ); Wed, 28 Dec 2022 06:04:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232847AbiL1LDp (ORCPT ); Wed, 28 Dec 2022 06:03:45 -0500 Received: from formenos.hmeau.com (helcar.hmeau.com [216.24.177.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6153A137; Wed, 28 Dec 2022 03:03:42 -0800 (PST) Received: from loth.rohan.me.apana.org.au ([192.168.167.2]) by formenos.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1pAUDc-00BYvN-Ek; Wed, 28 Dec 2022 19:03:33 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Wed, 28 Dec 2022 19:03:32 +0800 Date: Wed, 28 Dec 2022 19:03:32 +0800 From: Herbert Xu To: Uwe =?iso-8859-1?q?Kleine-K=F6nig?= 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: [v2 PATCH] crypto: caam - Avoid GCC memset bug warning Message-ID: References: <20221222162513.4021928-1-u.kleine-koenig@pengutronix.de> <20221223174719.4n6pmwio4zycj2qm@pengutronix.de> <20221228093917.zhkjpzc2ok5dc4ga@pengutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221228093917.zhkjpzc2ok5dc4ga@pengutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org On Wed, Dec 28, 2022 at 10:39:17AM +0100, Uwe Kleine-König wrote: > > Huh, broken encoding in the mail. I'd appreciate someone to doublecheck > it's fine in the final commit. > > Tested-by: Uwe Kleine-König Sorry. Let me try again: ---8<--- 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. A similar warning used to be generated by sparse but that was fixed years ago. 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önig Tested-by: Uwe Kleine-König Signed-off-by: Herbert Xu 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, const void *data, int len) { u32 *offset = desc_end(desc); - if (len) /* avoid sparse warning: memcpy with byte count of 0 */ + /* Avoid gcc warning: memcpy with data == NULL */ + if (!IS_ENABLED(CONFIG_CRYPTO_DEV_FSL_CAAM_DEBUG) || data) memcpy(offset, data, len); (*desc) = cpu_to_caam32(caam32_to_cpu(*desc) +