Skip to contentSkip to conversation

dt-bindings: trivial-devices: add atmel,atecc608a

PATCH In review Thorsten Blum 4 participants 5 messages Aug 30 – Sep 11

Subsystems (4)
lore
Share & tools
lore

Thorsten Blum

author maintainer
#0 lore raw

PATCH 1/2 dt-bindings: trivial-devices: add atmel,atecc608a

Add an entry for ATECC608A.

---
 Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/trivial-devices.yaml +2 -0
index 2de8eb09cb7d..3b7876c5a45d 100644
@@ -69,6 +69,8 @@ properties:
           - asteralabs,pt5161l
             # ATECC508A - i2c h/w elliptic curve crypto module
           - atmel,atecc508a
+            # ATECC608A - i2c h/w elliptic curve crypto module
+          - atmel,atecc608a
             # ATECC608B - i2c h/w elliptic curve crypto module
           - atmel,atecc608b
             # ATSHA204 - i2c h/w symmetric crypto module
author maintainer
#1 lore raw

PATCH 2/2 crypto: atmel-ecc - add support for atecc608a

The driver already supports the ATECC508A and ATECC608B and uses only commands shared by these devices.

Microchip documents the ATECC608B as a backwards-compatible, functional drop-in replacement for the ATECC608A, with the same device structure and command interface [1]. Therefore, add support for the ATECC608A.

ATECC608A hardware was not available for testing.

---
 drivers/crypto/atmel-ecc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/crypto/atmel-ecc.c +2 -0
index 075f38a67935..0904bb47fd0a 100644
@@ -348,6 +348,7 @@ static void atmel_ecc_remove(struct i2c_client *client)
 
 static const struct of_device_id atmel_ecc_dt_ids[] = {
 	{ .compatible = "atmel,atecc508a", },
+	{ .compatible = "atmel,atecc608a", },
 	{ .compatible = "atmel,atecc608b", },
 	{ }
 };
@@ -355,6 +356,7 @@ MODULE_DEVICE_TABLE(of, atmel_ecc_dt_ids);
 
 static const struct i2c_device_id atmel_ecc_id[] = {
 	{ .name = "atecc508a" },
+	{ .name = "atecc608a" },
 	{ .name = "atecc608b" },
 	{ }
 };
#2 lore raw

Re: [PATCH 2/2] crypto: atmel-ecc - add support for atecc608a

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Use-After-Free due to early return in atmel_ecc_remove() missing list deletion. --

commit da00b1f7ab58791bf49d80087ba781e30c9433d0
Author: Thorsten Blum <[email protected]>

crypto: atmel-ecc - add support for atecc608a

The driver already supports the ATECC508A and ATECC608B and uses only commands shared by these devices.

Microchip documents the ATECC608B as a backwards-compatible, functional drop-in replacement for the ATECC608A, with the same device structure and command interface [1]. Therefore, add support for the ATECC608A.

ATECC608A hardware was not available for testing.

drivers/crypto/atmel-ecc.c static void atmel_ecc_remove(struct i2c_client *client)

Quoted 5 lines
drivers/crypto/atmel-ecc.c +0 -0
index 075f38a67935c..0904bb47fd0a9 100644
@@ -348,6 +348,7 @@ static void atmel_ecc_remove(struct i2c_client *client)

[Severity: High]
This is a pre-existing issue, but can the early return in atmel_ecc_remove() cause a use-after-free?

If a user unbinds the ATECC device via sysfs while a crypto operation is in flight (tfm_count > 0):

drivers/crypto/atmel-ecc.c:atmel_ecc_remove() {
	...
	if (atomic_read(&i2c_priv->tfm_count)) {
		dev_emerg(&client->dev, "Device is busy, expect memory corruption.\n");
		return;
	}
	...
	list_del(&i2c_priv->i2c_client_list_node);
	...
}

The early return bypasses list_del(&i2c_priv->i2c_client_list_node). The driver core then frees the devm_kmalloc-allocated i2c_priv, leaving a freed node on the global driver_data.i2c_client_list.

The next time any crypto operation is requested, atmel_ecc_i2c_client_alloc() will iterate over the list and access the freed i2c_priv node, causing a use-after-free.

Does it make sense to always remove the node from the list before returning?

Quoted 7 lines
drivers/crypto/atmel-ecc.c +1 -0
 static const struct of_device_id atmel_ecc_dt_ids[] = {
 	{ .compatible = "atmel,atecc508a", },
+	{ .compatible = "atmel,atecc608a", },
 	{ .compatible = "atmel,atecc608b", },
 	{ }
 };
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2