From: Eric Biggers <ebiggers@kernel.org>
To: linux-crypto@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Ard Biesheuvel <ardb@kernel.org>,
"Jason A . Donenfeld" <Jason@zx2c4.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
linux-hardening@vger.kernel.org, Kees Cook <kees@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH 0/6] lib/crypto: More at_least decorations
Date: Sat, 22 Nov 2025 20:00:37 -0800 [thread overview]
Message-ID: <20251123040037.GA42791@sol> (raw)
In-Reply-To: <20251122194206.31822-1-ebiggers@kernel.org>
On Sat, Nov 22, 2025 at 11:42:00AM -0800, Eric Biggers wrote:
> This series depends on the 'at_least' macro added by
> https://lore.kernel.org/r/20251122025510.1625066-4-Jason@zx2c4.com
> It can also be retrieved from
>
> git fetch https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git more-at-least-decorations-v1
>
> Add the at_least (i.e. 'static') decoration to the fixed-size array
> parameters of more of the crypto library functions. This causes clang
> to generate a warning if a too-small array of known size is passed.
>
> Eric Biggers (6):
> lib/crypto: chacha: Add at_least decoration to fixed-size array params
> lib/crypto: curve25519: Add at_least decoration to fixed-size array
> params
> lib/crypto: md5: Add at_least decoration to fixed-size array params
> lib/crypto: poly1305: Add at_least decoration to fixed-size array
> params
> lib/crypto: sha1: Add at_least decoration to fixed-size array params
> lib/crypto: sha2: Add at_least decoration to fixed-size array params
>
> include/crypto/chacha.h | 12 ++++-----
> include/crypto/curve25519.h | 24 ++++++++++-------
> include/crypto/md5.h | 11 ++++----
> include/crypto/poly1305.h | 2 +-
> include/crypto/sha1.h | 12 +++++----
> include/crypto/sha2.h | 53 ++++++++++++++++++++++---------------
It turns out this causes a build error when <crypto/poly1305.h>,
<crypto/sha1.h>, or <crypto/sha2.h> is included before
<linux/compiler.h>.
Jason's patch to <crypto/chacha20poly1305.h> is okay, because that one
indirectly includes <linux/compiler.h> by chance.
I thought <linux/compiler.h> already got included in everything via the
-include compiler flag. But it's actually <linux/compiler_types.h>
which works that way, not <linux/compiler.h> which is a regular header.
We can make these crypto headers include <linux/compiler.h>. But before
we do that, should we perhaps consider putting the definition of
'at_least' in <linux/compiler_types.h> instead of in <linux/compiler.h>,
so that it becomes always available? This is basically a core language
feature. Maybe it belongs next to the definition of __counted_by, which
is another definition related to array bounds?
- Eric
next prev parent reply other threads:[~2025-11-23 4:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-22 19:42 [PATCH 0/6] lib/crypto: More at_least decorations Eric Biggers
2025-11-22 19:42 ` [PATCH 1/6] lib/crypto: chacha: Add at_least decoration to fixed-size array params Eric Biggers
2025-11-22 19:42 ` [PATCH 2/6] lib/crypto: curve25519: " Eric Biggers
2025-11-22 19:42 ` [PATCH 3/6] lib/crypto: md5: " Eric Biggers
2025-11-22 19:42 ` [PATCH 4/6] lib/crypto: poly1305: " Eric Biggers
2025-11-22 19:42 ` [PATCH 5/6] lib/crypto: sha1: " Eric Biggers
2025-11-22 19:42 ` [PATCH 6/6] lib/crypto: sha2: " Eric Biggers
2025-11-22 21:00 ` [PATCH 0/6] lib/crypto: More at_least decorations Jason A. Donenfeld
2025-11-23 4:00 ` Eric Biggers [this message]
2025-11-23 5:16 ` Jason A. Donenfeld
2025-11-23 5:17 ` Eric Biggers
2025-11-23 8:31 ` Ard Biesheuvel
2025-11-23 20:35 ` Eric Biggers
2025-11-23 20:38 ` Jason A. Donenfeld
2025-11-23 20:54 ` Eric Biggers
2025-11-24 19:17 ` Kees Cook
2025-11-23 20:31 ` Eric Biggers
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=20251123040037.GA42791@sol \
--to=ebiggers@kernel.org \
--cc=Jason@zx2c4.com \
--cc=ardb@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=kees@kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).