Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1007782rdg; Fri, 11 Aug 2023 07:06:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFL3SUlfNTMpDXPoi0E1NZshzZLQ9JCnsheLA2WczhDa2UkagiR7iN6SyA/1sDg+BClaury X-Received: by 2002:a05:6e02:216e:b0:349:3836:c40f with SMTP id s14-20020a056e02216e00b003493836c40fmr2655202ilv.23.1691762771355; Fri, 11 Aug 2023 07:06:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691762771; cv=none; d=google.com; s=arc-20160816; b=0OyjHsrPa2Ig4Z7/HVXu0cD4/2EXHX6vy29IjIQZmIdD+VX9dSOCMbcfiKHQ06K/EK N4zoOd12nBSqzeZiYz2287gBRIOepV9tJ1inmTc9uf9d73OOpj7ung5H5ze/uPQkCzKa WtZYV4sFrvyvm7KKg34r4VhGKYU/3BmoQUxbh7tKhr13F8+m5ynXdvR1ISBfwPt9e1O1 FwzMRtEFc9Q55jO7Q3GSxUuJ9c18+OjdZaFGPKzu35Xou0CIOWIbWW2oaE7X/PAXBmaD xffnIGi55dIMNt9X38BJCI8DYCHNveKN47Y3iy0KRLkSjoAY8rNb+bZmoAC+ZZuXGCbO +Arg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:feedback-id:dkim-signature :dkim-signature; bh=FS1HpjgV5XWBmUntM3Uxn3bym8vCanuc3UC0yqx/KW8=; fh=JKDU72pD27l6HxlAbrBnpUSPMd3Z3Sf6ih2v/EX+1T0=; b=KyGF6E0wyVyi4WIlO+Fc9N/vZi+CFo8lJHF0o64tPhSPe2LmsQdZ+H4g7/divIGiu1 sZGr97ecpqQLGa3GuLB8mok5zAaGz991mI4PmBy2F7VcDIdz4jhVUQl1JmA3/+Z08/2I mLHkjbEfungnpgmVmJTQt3bS97Mbbz8G2+8CkitEf86k9M58SN8i3hKjJaemHncDWvmH 226zNdeS0QsdWD9iFOsfGLG2SROT04HVUFI1R6VYomUZz+VT3kHvkuU9QXZwZaebL5MQ SG07TQXaK6MgWITOvMYAyB/A5lIRyufuRC6unyjootNCjjXMBZlToxSRiJbY1cxZ/8WV X0HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm3 header.b=PjWFWT7U; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=TQQbf3Mu; 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 z9-20020a63e549000000b00563519244cdsi3603680pgj.625.2023.08.11.07.05.50; Fri, 11 Aug 2023 07:06:11 -0700 (PDT) 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=@arndb.de header.s=fm3 header.b=PjWFWT7U; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=TQQbf3Mu; 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 S230217AbjHKNi1 (ORCPT + 99 others); Fri, 11 Aug 2023 09:38:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229645AbjHKNi1 (ORCPT ); Fri, 11 Aug 2023 09:38:27 -0400 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB022ED; Fri, 11 Aug 2023 06:38:25 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 386155C0099; Fri, 11 Aug 2023 09:38:22 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute6.internal (MEProxy); Fri, 11 Aug 2023 09:38:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1691761102; x=1691847502; bh=FS 1HpjgV5XWBmUntM3Uxn3bym8vCanuc3UC0yqx/KW8=; b=PjWFWT7UYzW6ZfAj/J +Fv0hoZeXq1YPNcyENya6gIijy0/PaUqhYLzhnJOSUDkE516eFZoBAGizkzTJnfy lEx7X0vVkxfxe042X95w84QlYp7eTFHTyQFdsBEBUU3hOzJt6sdD1kE579iQkcze V35ou5vqgW8N59ufIH4nyi56/4Hp6pq9c9R5LOksMs8XiO1cebkdaUbzqnlgVwff AF+N9/nHH8zdURpPexWi49qaOUx6xfCO1xkEN3EhLgVb43OTJcKQkc3s00dvsi7n /JRzdsAEaEpopFdezS8gO0767iVhG+dHmKjVBj/9D3wFbJU5O3TFNWpCg+KMtUpF JDIg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1691761102; x=1691847502; bh=FS1HpjgV5XWBm UntM3Uxn3bym8vCanuc3UC0yqx/KW8=; b=TQQbf3Mu01WkJwzGpHKzbchWQj16P I+klZ0U7DlPXKh1YREsN8OgtsU+H/J/Yg0yorNWJQnwHTokM4qgHBJA4sy1tpY3R FMtfBrqNyGSawXBMSkJ2YpW9rAZuy4cs+ba0XntzIji73wPOU4WJiSbngxU2zgNM nMvvxWjWD36dbDxvhWb2RgcpvIB+nR84VsbzhUP1GZSdehRyyo0395Pi3urK4f7F w8meh4ysQ7QYZvrB5721d+sd6euOXKlkCZzVlq5lOLQ+Itx8DH5dDk/9beIOflAK wt61ohFhF7UC5YmboL4WcaCWyaTIZV+0dJys/3D4GxLbr3gGoeEwmpG9w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrleekgdeihecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvvefutgesthdtredtreertdenucfhrhhomhepfdetrhhn ugcuuegvrhhgmhgrnhhnfdcuoegrrhhnugesrghrnhgusgdruggvqeenucggtffrrghtth gvrhhnpeffheeugeetiefhgeethfejgfdtuefggeejleehjeeutefhfeeggefhkedtkeet ffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrrh hnugesrghrnhgusgdruggv X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id AB450B60089; Fri, 11 Aug 2023 09:38:20 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-624-g7714e4406d-fm-20230801.001-g7714e440 Mime-Version: 1.0 Message-Id: <8c3b242f-7d6f-4bec-9a44-61ac65a26637@app.fastmail.com> In-Reply-To: References: <20230724135327.1173309-1-arnd@kernel.org> Date: Fri, 11 Aug 2023 15:38:00 +0200 From: "Arnd Bergmann" To: "Herbert Xu" , "Linus Torvalds" , "Eric Dumazet" , "Jakub Kicinski" Cc: "Arnd Bergmann" , "Alexandre Belloni" , "Ryan Wanner" , "Yangtao Li" , linux-kernel@vger.kernel.org, "David S . Miller" , "Sergiu Moga" , "Ayush Sawal" , "Gaosheng Cui" , "Claudiu Beznea" , linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, "Kees Cook" Subject: Re: [PATCH 1/2] crypto: drivers - avoid memcpy size warning Content-Type: text/plain 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_BLOCKED, SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED 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 Fri, Aug 11, 2023, at 12:48, Herbert Xu wrote: > On Mon, Aug 07, 2023 at 02:04:05PM +0200, Arnd Bergmann wrote: > > struct atmel_sha_hmac_ctx *hmac = crypto_ahash_ctx(tfm); > size_t bs = ctx->block_size; > > memcpy(hmac->opad, hmac->ipad, bs); > > The block_size is set by the algorithm, you can easily grep for > it in atmel-sha.c and the biggest one there is SHA512_BLOCK_SIZE, > which is how big hmac->ipad/hmac->opad are. > > So logically this code is perfectly fine. Right, that was my conclusion as well. > There is no way for the compiler to know how big ctx->block_size is. > So why do we expect it to make deductions on how big bs can be? > > This warning looks broken to me. I'm still unsure how exactly it goes wrong here, but I suspect it works as designed and just happens to run into a case in these drivers that is just not that common. I also see that the kernel's memcpy() declaration is missing the "restrict" annotation, but the fortified version calls the __builtin_memcpy() variant that has an implicit prototype with those annotations. > It looks like there is already a solution to this though. Just use > unsafe_memcpy and be done with it. Fine with me, I'll send a new version doing that. Arnd