Re: [PATCH v4] crypto: atmel-ecc - fix missing ECDH public key validation
From: Thorsten Blum
Date: Sun Nov 29 2026 - 10:01:14 EST
v4 fails to apply with the following error:
patch fragment without header at line 71: @@ -146,6 +148,20 @@ static int atmel_ecdh_generate_public_key(struct kpp_request *req)
More comments below.
On Sat, Nov 28, 2026 at 09:51:00PM +0000, Ryan Prinz wrote:
> atmel_ecdh_compute_shared_secret() passes the peer's ECDH public point
> to the ATECC508A/608A/608B secure element without software validation;
> only req->src_len is checked.
>
> Validate the point in software before it reaches the I2C command, the
> same check crypto_ecdh_shared_secret() performs for the generic
> "ecdh-nist-p256" implementation: call ecc_is_pubkey_valid_partial()
> and reject the request if it fails.
>
> Fixes: 11105693fa05 ("crypto: atmel-ecc - introduce Microchip / Atmel ECC driver")
> Signed-off-by: Ryan Prinz <rc4d5a@xxxxxxxxxxxxxx>
> ---
[...]
> This has not been tested on hardware.
[...]
> AI Disclosure: An AI assistant was used to assist with the
> analysis and testing. I have verified the vulnerability, the fix, and
> the test results myself and take responsibility for this contribution,
> per Documentation/process/coding-assistants.rst.
The Fixes: tag should be fine, but please drop "I have verified the
vulnerability, the fix, and the test results myself". Your notes say it
wasn't tested on hardware, and there's no evidence the device accepts a
bad key.
> --- a/drivers/crypto/atmel-ecc.c
> +++ b/drivers/crypto/atmel-ecc.c
> @@ -17,8 +17,10 @@
> #include <linux/of.h>
> #include <linux/scatterlist.h>
> #include <linux/slab.h>
> #include <linux/workqueue.h>
> -#include <crypto/internal/kpp.h>
> -#include <crypto/ecdh.h>
> -#include <crypto/kpp.h>
> +#include <crypto/ecc_curve.h>
> +#include <crypto/ecdh.h>
> +#include <crypto/internal/ecc.h>
> +#include <crypto/internal/kpp.h>
> +#include <crypto/kpp.h>
> #include "atmel-i2c.h"
Sorry, I should have been clearer about the grouping. I'd keep
<crypto/internal/*> as a group before the other <crypto/*> includes,
with each group sorted. That also keeps the diff small:
+#include <crypto/internal/ecc.h>
#include <crypto/internal/kpp.h>
+#include <crypto/ecc_curve.h>
#include <crypto/ecdh.h>
#include <crypto/kpp.h>
> +static int atmel_ecdh_peer_pubkey_valid(const u8 *pubkey_buf)
The function name reads like a predicate, but it returns 0 or an errno.
atmel_ecdh_validate_peer_pubkey() would be clearer imo.
Thanks,
Thorsten