Skip to contentSkip to conversation

lib/crypto: poly1305: Use memzero_explicit() in poly1305_final()

PATCH Applied Eric Biggers 2 participants 4 messages Oct 6 – Oct 9

Subsystems (3)
lore
Share & tools
lore

Eric Biggers

author maintainer
#0 lore raw

PATCH 1/1 lib/crypto: poly1305: Use memzero_explicit() in poly1305_final()

Use memzero_explicit() instead of a plain struct assignment to guarantee zeroization of the 'struct poly1305_desc_ctx'.

Note that dead store elimination was only theoretically possible with link-time optimization here. But it's still worth fixing.

Fixes a1d93064094c ("crypto: poly1305 - expose init/update/final library interface")
---
 lib/crypto/poly1305.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/crypto/poly1305.c +1 -1
index f313ccc4b4dd2..048c7afe86138 100644
@@ -78,7 +78,7 @@ void poly1305_final(struct poly1305_desc_ctx *desc, u8 *dst)
 	}
 
 	poly1305_emit(&desc->state.h, dst, desc->s);
-	*desc = (struct poly1305_desc_ctx){};
+	memzero_explicit(desc, sizeof(*desc));
 }
 EXPORT_SYMBOL(poly1305_final);
 

base-commit: 6a50ce0af5c91fd665d65d357af8ae55db1df7d0

Signature · 1 line
2.56.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Eric Biggers

Use memzero_explicit() instead of a plain struct assignment to guarantee zeroization of the 'struct poly1305_desc_ctx'.

Note that dead store elimination was only theoretically possible with link-time optimization here. But it's still worth fixing.

Fixes a1d93064094c ("crypto: poly1305 - expose init/update/final

library interface")

Quoted 9 lines

Closes:
https://sashiko.dev/#/bug/linux-c3a6bd76-f6ab-4203-892a-cd06f7aa0c34

---
 lib/crypto/poly1305.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 17 lines
lib/crypto/poly1305.c +1 -1
index f313ccc4b4dd2..048c7afe86138 100644
@@ -78,7 +78,7 @@ void poly1305_final(struct poly1305_desc_ctx *desc, u8 *dst)
 	}
 
 	poly1305_emit(&desc->state.h, dst, desc->s);
-	*desc = (struct poly1305_desc_ctx){};
+	memzero_explicit(desc, sizeof(*desc));
 }
 EXPORT_SYMBOL(poly1305_final);
 

base-commit: 6a50ce0af5c91fd665d65d357af8ae55db1df7d0

Signature · 1 line
2.56.0
author maintainer Applied
#2 lore raw
In reply to Eric Biggers
Quoted 6 lines · Eric Biggers

Use memzero_explicit() instead of a plain struct assignment to guarantee zeroization of the 'struct poly1305_desc_ctx'.

Note that dead store elimination was only theoretically possible with link-time optimization here. But it's still worth fixing.

Quoted 8 lines
Fixes a1d93064094c ("crypto: poly1305 - expose init/update/final library interface")
---
 lib/crypto/poly1305.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/log/?h=libcrypto-next

- Eric

author maintainer
#3 lore raw
Quoted 16 lines · Eric Biggers
Quoted 6 lines · Eric Biggers

Use memzero_explicit() instead of a plain struct assignment to guarantee zeroization of the 'struct poly1305_desc_ctx'.

Note that dead store elimination was only theoretically possible with link-time optimization here. But it's still worth fixing.

Quoted 8 lines
Fixes a1d93064094c ("crypto: poly1305 - expose init/update/final library interface")
---
 lib/crypto/poly1305.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 1 line

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/log/?h=libcrypto-next

Moved to libcrypto-fixes, since will be a fixes pull request with other Poly1305 fixes anyway.

- Eric