Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1401144rwb; Thu, 1 Dec 2022 17:13:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf4JyoB5uCjZ3ANOz6+6i4x745A/zu6Dur2MfVmGTFj3n2Hb22vgMXoAed+4blZezXRwloLZ X-Received: by 2002:a05:6402:5406:b0:467:4b3d:f2ed with SMTP id ev6-20020a056402540600b004674b3df2edmr45247103edb.101.1669943590111; Thu, 01 Dec 2022 17:13:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669943590; cv=none; d=google.com; s=arc-20160816; b=1Jbg0Bi0vNzqBpNt/vFDjw93umDg/cUDqs+/B11EJm86RvDIG+psicwLhE6+n7ck++ OrNvBSpEzs1ol5rIX3pqFIUSiElGYLFHGaYsbixY7wdN2puE6u1veWm9B5WbczkwQVJX aE4uWb7D4FN1nNMpEYXNit9KhnPaai6sIx0BZ7MCXQz1u7X6j+fs9BL69yoRVSXU3aVa 6bGLK/CxJKjibGCZSzdypufPaoQS/bmG/v5EZMyYT6HaxCQsa7eBIJf3PouEqfVXoaK3 y1bXdvoXui3JPQx0xJEaScd9gq019mJVg/+mYaIGyHCLu2M0zLhOiOhN1sQH/fqq6GyM IEgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=MxkuzgUgTifQFdxhVWtsmKUpSCQdyimcV2FkUnufBLc=; b=RuNFhtZ4eoPNd88RmsmVLiGv0udYO1r8z+xBOVhF3XM1uq1h+FQgnzB4mZjmw7xHCE JP/N9DxABHJQD1KWlCFfegmurL8E8+UsnHyNo6l+2ys3dH88PtvcvipZ55fHx2GaC4az 6vaY0zW9ILygAhuolDSqqwoe6cDRG554ef5Wp9Q17r+n5PwHl50bkUQI9rQPMDmZpP+O v29/e82WkfdEhW6L9nxj2a6FxwUBZA4Ry+u7m2k3SvdEuR/GHerSW52818lU8BwHA1jv /9KKDe9rdaf5mxjivVxew1UNQQWms0cJfrrl51fgUjkBOuz1m6zQSwcudAto67BmEF8b 1Rpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hEKWleQh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sd31-20020a1709076e1f00b0078d83fb6672si5626800ejc.118.2022.12.01.17.12.38; Thu, 01 Dec 2022 17:13:10 -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; dkim=pass header.i=@linaro.org header.s=google header.b=hEKWleQh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231719AbiLBA6V (ORCPT + 99 others); Thu, 1 Dec 2022 19:58:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231421AbiLBA6U (ORCPT ); Thu, 1 Dec 2022 19:58:20 -0500 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 148DD31EEF for ; Thu, 1 Dec 2022 16:58:19 -0800 (PST) Received: by mail-lf1-x12e.google.com with SMTP id p8so5107292lfu.11 for ; Thu, 01 Dec 2022 16:58:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=MxkuzgUgTifQFdxhVWtsmKUpSCQdyimcV2FkUnufBLc=; b=hEKWleQh2i+coIcgnXZbCte2WweMX/4rdEPNBC4I72YPpG558YYdUC4fOePrPsorTm EHPrqFfQsXLYlxX2BcJfTnzEoMNfkMDARFrw9zWcv2rvRuq47qOzVq7h3tzi2rM6UrgV T9I/XGQ8zYHn5ePdix76dWi26hvtQt9cjY26rSG+R7eRGCwqy7Pibsgxy+XiDgud+2RW 6DloAOKq3Cn5k/2bNPsTZMwO9Gf5PVje3i79eHmMzYCh0Y5K7DH2ImTv54BklKMpeY6/ DIs5AhoOB3wOf+bQNB+nAi48QTPsPJ2I5r1Xw8Nj5Ixxawy26rPBYAGupqgVqXkouDHC xzTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MxkuzgUgTifQFdxhVWtsmKUpSCQdyimcV2FkUnufBLc=; b=1duhigzqU/duk1j7C/qbedciIlZxziVGVPp16x/iFe5GzsGbfUCU7pjmau6rwuqqmj +pzwFdK/37gGCuuOtI0PuYMw+W9HXE+B2aQG9GAjQTBy7ROxOp4A/TQj2U/6qXBxhWIN pRxam5uve1W9ZaQ2Scjmo/Tqx8pQ2Nockg1WYTc/3HdGGqTfhLoNGcGHTuH9IOd91SgN iKTyUT7Et3bE3wbvsxT+RyZqQYgZI+1XduQHtpZrws7vg8SZxpyaIkgfKlMbMgALypOn CX6gsm3LqOm1CZsGmlBrzGNO+1S+fYz/w+bOSugalJFJAVto6SqbySh8AB+RIo2AGzAe ctoQ== X-Gm-Message-State: ANoB5pmzqZD06Vlqyrk7weoQC/kRzFfNsTH/9N4GYxnZJLvvf6R+GGXc tzVahEbeZV/vorYxdigDEN2NAnmG/c5vK7cQ X-Received: by 2002:ac2:558c:0:b0:4a2:4b78:a8e8 with SMTP id v12-20020ac2558c000000b004a24b78a8e8mr19587673lfg.292.1669942697389; Thu, 01 Dec 2022 16:58:17 -0800 (PST) Received: from mutt (c-e429e555.07-21-73746f28.bbcust.telenor.se. [85.229.41.228]) by smtp.gmail.com with ESMTPSA id s22-20020a056512315600b004979e1ff641sm815816lfi.115.2022.12.01.16.58.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 16:58:16 -0800 (PST) Date: Fri, 2 Dec 2022 01:58:14 +0100 From: Anders Roxell To: Kees Cook Cc: Horia =?utf-8?Q?Geant=C4=83?= , Pankaj Gupta , Gaurav Jain , Herbert Xu , "David S. Miller" , linux-crypto@vger.kernel.org, kernel test robot , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] crypto/caam: Avoid GCC constprop bug warning Message-ID: <20221202005814.GD69385@mutt> References: <20221028210527.never.934-kees@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20221028210527.never.934-kees@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 On 2022-10-28 14:05, Kees Cook wrote: > GCC 12 appears to perform constant propagation incompletely(?) and can > no longer notice that "len" is always 0 when "data" is NULL. Expand the > check to avoid warnings about memcpy() having a NULL argument: > > ... > from drivers/crypto/caam/key_gen.c:8: > drivers/crypto/caam/desc_constr.h: In function 'append_data.constprop': > include/linux/fortify-string.h:48:33: warning: argument 2 null where non-null expected [-Wnonnull] > 48 | #define __underlying_memcpy __builtin_memcpy > | ^ > include/linux/fortify-string.h:438:9: note: in expansion of macro '__underlying_memcpy' > 438 | __underlying_##op(p, q, __fortify_size); \ > | ^~~~~~~~~~~~~ > > The NULL was being propagated from: > > append_fifo_load_as_imm(desc, NULL, 0, LDST_CLASS_2_CCB | > FIFOLD_TYPE_MSG | FIFOLD_TYPE_LAST2); > ... > static inline void append_##cmd##_as_imm(u32 * const desc, const void *data, \ > unsigned int len, u32 options) \ > { \ > PRINT_POS; \ > append_cmd_data(desc, data, len, CMD_##op | options); \ > } > ... > APPEND_CMD_PTR_TO_IMM(fifo_load, FIFO_LOAD); > ... > static inline void append_cmd_data(u32 * const desc, const void *data, int len, > u32 command) > { > append_cmd(desc, command | IMMEDIATE | len); > append_data(desc, data, len); > } > > Cc: "Horia Geantă" > Cc: Pankaj Gupta > Cc: Gaurav Jain > Cc: Herbert Xu > Cc: "David S. Miller" > Cc: linux-crypto@vger.kernel.org > Reported-by: kernel test robot > Link: https://lore.kernel.org/lkml/202210290446.qBayTfzl-lkp@intel.com > Signed-off-by: Kees Cook Tested-by: Anders Roxell > --- > drivers/crypto/caam/desc_constr.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/crypto/caam/desc_constr.h b/drivers/crypto/caam/desc_constr.h > index 62ce6421bb3f..ddbba8b00ab7 100644 > --- a/drivers/crypto/caam/desc_constr.h > +++ b/drivers/crypto/caam/desc_constr.h > @@ -163,7 +163,7 @@ 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 */ > + if (data && len) /* avoid sparse warning: memcpy with byte count of 0 */ Maybe we should update the comment, since newer releases of sparse doesn't warn about this. Cheers, Anders