* [PATCH 1/2] crypto: keembay - use crypto_memneq() to compare GCM AEAD tags
@ 2026-08-07 16:13 David C.C.M. Gall
2026-08-15 1:31 ` Herbert Xu
0 siblings, 1 reply; 2+ messages in thread
From: David C.C.M. Gall @ 2026-08-07 16:13 UTC (permalink / raw)
To: Herbert Xu, David S. Miller, linux-crypto, linux-kernel; +Cc: gregkh
Use crypto_memneq() for constant-time comparison.
The GCM path in keembay-ocs-aes-core.c verifes the received
authentication tag with memcmp(), which returns early on the first
mismatched byte. This leaks valid-prefix length and allows for valid
tag forgery which violates the INT-CTXT guarantee of AEAD.
Assisted-by: gregkh_clanker_t1000
Signed-off-by: David C.C.M. Gall <david.ccm.gall@googlemail.com>
---
drivers/crypto/intel/keembay/keembay-ocs-aes-core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/crypto/intel/keembay/keembay-ocs-aes-core.c b/drivers/crypto/intel/keembay/keembay-ocs-aes-core.c
index 8a8f6c81e010..f8f4517ccad0 100644
--- a/drivers/crypto/intel/keembay/keembay-ocs-aes-core.c
+++ b/drivers/crypto/intel/keembay/keembay-ocs-aes-core.c
@@ -11,6 +11,7 @@
#include <crypto/internal/aead.h>
#include <crypto/internal/skcipher.h>
#include <crypto/scatterwalk.h>
+#include <crypto/utils.h>
#include <linux/clk.h>
#include <linux/completion.h>
#include <linux/dma-mapping.h>
@@ -919,7 +920,7 @@ static int kmb_ocs_aead_run(struct aead_request *req)
/* For GCM decrypt, we have to compare in_tag with out_tag. */
if (rctx->instruction == OCS_DECRYPT) {
- rc = memcmp(rctx->in_tag, rctx->out_tag, tag_size) ?
+ rc = crypto_memneq(rctx->in_tag, rctx->out_tag, tag_size) ?
-EBADMSG : 0;
goto exit;
}
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH 1/2] crypto: keembay - use crypto_memneq() to compare GCM AEAD tags
2026-08-07 16:13 [PATCH 1/2] crypto: keembay - use crypto_memneq() to compare GCM AEAD tags David C.C.M. Gall
@ 2026-08-15 1:31 ` Herbert Xu
0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2026-08-15 1:31 UTC (permalink / raw)
To: David C.C.M. Gall; +Cc: David S. Miller, linux-crypto, linux-kernel, gregkh
On Fri, Aug 07, 2026 at 06:13:52PM +0200, David C.C.M. Gall wrote:
> Use crypto_memneq() for constant-time comparison.
>
> The GCM path in keembay-ocs-aes-core.c verifes the received
> authentication tag with memcmp(), which returns early on the first
> mismatched byte. This leaks valid-prefix length and allows for valid
> tag forgery which violates the INT-CTXT guarantee of AEAD.
>
> Assisted-by: gregkh_clanker_t1000
> Signed-off-by: David C.C.M. Gall <david.ccm.gall@googlemail.com>
> ---
> drivers/crypto/intel/keembay/keembay-ocs-aes-core.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
All applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-15 1:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-07 16:13 [PATCH 1/2] crypto: keembay - use crypto_memneq() to compare GCM AEAD tags David C.C.M. Gall
2026-08-15 1:31 ` Herbert Xu
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®