diff mbox series

[v2] crypto: chacha20poly1305 - Annotate struct chachapoly_ctx with __counted_by()

Message ID 20240805221129.2644-2-thorsten.blum@toblux.com
State Accepted
Commit 18e2188c4b2069cf52c12344b47b4f7ac982f555
Headers show
Series [v2] crypto: chacha20poly1305 - Annotate struct chachapoly_ctx with __counted_by() | expand

Commit Message

Thorsten Blum Aug. 5, 2024, 10:11 p.m. UTC
Add the __counted_by compiler attribute to the flexible array member
salt to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
CONFIG_FORTIFY_SOURCE.

Reviewed-by: Kees Cook <kees@kernel.org>
Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
---
Changes in v2:
- Drop using struct_size_t() as suggested by Eric Biggers and Kees Cook
- Link to v1: https://lore.kernel.org/linux-kernel/20240805175237.63098-2-thorsten.blum@toblux.com/
---
 crypto/chacha20poly1305.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Herbert Xu Aug. 17, 2024, 7:07 a.m. UTC | #1
On Tue, Aug 06, 2024 at 12:11:30AM +0200, Thorsten Blum wrote:
> Add the __counted_by compiler attribute to the flexible array member
> salt to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
> CONFIG_FORTIFY_SOURCE.
> 
> Reviewed-by: Kees Cook <kees@kernel.org>
> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
> ---
> Changes in v2:
> - Drop using struct_size_t() as suggested by Eric Biggers and Kees Cook
> - Link to v1: https://lore.kernel.org/linux-kernel/20240805175237.63098-2-thorsten.blum@toblux.com/
> ---
>  crypto/chacha20poly1305.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Patch applied.  Thanks.
diff mbox series

Patch

diff --git a/crypto/chacha20poly1305.c b/crypto/chacha20poly1305.c
index 9e4651330852..d740849f1c19 100644
--- a/crypto/chacha20poly1305.c
+++ b/crypto/chacha20poly1305.c
@@ -27,7 +27,7 @@  struct chachapoly_ctx {
 	struct crypto_ahash *poly;
 	/* key bytes we use for the ChaCha20 IV */
 	unsigned int saltlen;
-	u8 salt[];
+	u8 salt[] __counted_by(saltlen);
 };
 
 struct poly_req {