mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Herbert Xu" <herbert@gondor.apana.org.au>,
	"Linus Torvalds" <torvalds@linux-foundation.org>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>
Cc: "Arnd Bergmann" <arnd@kernel.org>,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	"Ryan Wanner" <Ryan.Wanner@microchip.com>,
	"Yangtao Li" <frank.li@vivo.com>,
	linux-kernel@vger.kernel.org,
	"David S . Miller" <davem@davemloft.net>,
	"Sergiu Moga" <sergiu.moga@microchip.com>,
	"Ayush Sawal" <ayush.sawal@chelsio.com>,
	"Gaosheng Cui" <cuigaosheng1@huawei.com>,
	"Claudiu Beznea" <claudiu.beznea@microchip.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-crypto@vger.kernel.org, "Kees Cook" <keescook@chromium.org>
Subject: Re: [PATCH 1/2] crypto: drivers - avoid memcpy size warning
Date: Fri, 11 Aug 2023 15:38:00 +0200	[thread overview]
Message-ID: <8c3b242f-7d6f-4bec-9a44-61ac65a26637@app.fastmail.com> (raw)
In-Reply-To: <ZNYSFWA3WNAdRqfg@gondor.apana.org.au>

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

      reply	other threads:[~2023-08-11 13:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-24 13:53 Arnd Bergmann
2023-07-24 13:53 ` [PATCH 2/2] [v2] kallsyms: rework symbol lookup return codes Arnd Bergmann
2023-07-24 19:28   ` Luis Chamberlain
2023-07-26  8:02   ` Jiri Olsa
2023-07-26 13:54     ` Arnd Bergmann
2023-07-27  5:46 ` [PATCH 1/2] crypto: drivers - avoid memcpy size warning claudiu beznea
2023-08-04  8:16 ` Herbert Xu
2023-08-07 12:04   ` Arnd Bergmann
2023-08-11 10:48     ` Herbert Xu
2023-08-11 13:38       ` Arnd Bergmann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8c3b242f-7d6f-4bec-9a44-61ac65a26637@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=Ryan.Wanner@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=arnd@kernel.org \
    --cc=ayush.sawal@chelsio.com \
    --cc=claudiu.beznea@microchip.com \
    --cc=cuigaosheng1@huawei.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=frank.li@vivo.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=keescook@chromium.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sergiu.moga@microchip.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®