From patchwork Wed Dec 28 08:46:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 637330 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 4CC5EC3DA7A for ; Wed, 28 Dec 2022 08:49:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232743AbiL1ItW (ORCPT ); Wed, 28 Dec 2022 03:49:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232808AbiL1Is4 (ORCPT ); Wed, 28 Dec 2022 03:48:56 -0500 Received: from formenos.hmeau.com (helcar.hmeau.com [216.24.177.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B467CE72; Wed, 28 Dec 2022 00:46:53 -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 1pAS59-00BTqH-2k; Wed, 28 Dec 2022 16:46:40 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Wed, 28 Dec 2022 16:46:39 +0800 Date: Wed, 28 Dec 2022 16:46:39 +0800 From: Herbert Xu To: Uwe =?iso-8859-1?q?Kleine-K=F6nig?= Cc: Horia =?utf-8?q?Geant=C4=83?= , Gaurav Jain , Pankaj Gupta , linux-crypto@vger.kernel.org, kernel@pengutronix.de, "David S. Miller" , Kees Cook , kernel test robot , Anders Roxell , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] crypto: caam - Avoid GCC memset bug warning Message-ID: References: <20221222162513.4021928-1-u.kleine-koenig@pengutronix.de> <20221223174719.4n6pmwio4zycj2qm@pengutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221223174719.4n6pmwio4zycj2qm@pengutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org 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 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) +