Skip to content

crypto: atmel - introduce shared i2c core client management and capability-based selection framework

Lothar Rubusch linux-arm-kernel linux-crypto lkml 4 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest12 patches 0 repliesNew
  2. v312 patches 2 repliesSuperseded
  3. v212 patches 0 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v112 patches0 repliesSuperseded

Changes in v4 from the cover letter

- sashiko feedback[3]
- fixes and patches reordered
- fix: cover a possible memory leak at deregistration and subsequent reregistration
[3] https://sashiko.dev/#/patchset/20260520155703.23018-1-l.rubusch%40gmail.com

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12crypto: atmel-ecc - fix use after free situationdrivers/crypto/atmel-ecc.c drivers/crypto/atmel-i2c.h+12 -00 replies
2/12crypto: atmel-ecc - fix multi-device kpp registrationdrivers/crypto/atmel-ecc.c drivers/crypto/atmel-i2c.h+82 -260 replies
3/12crypto: atmel-sha204a - fix heap info leak on I2C transfer failuredrivers/crypto/atmel-sha204a.c+6 -10 replies
4/12crypto: atmel-ecc - rename driver_data before moving it into atmel-i2cdrivers/crypto/atmel-ecc.c+19 -200 replies
5/12crypto: atmel - rename atmel_ecc_driver_data to atmel_i2c_client_mgmtdrivers/crypto/atmel-ecc.c drivers/crypto/atmel-i2c.h+2 -20 replies
6/12crypto: atmel-i2c - move client management instance into coredrivers/crypto/atmel-ecc.c drivers/crypto/atmel-i2c.c drivers/crypto/atmel-i2c.h+7 -40 replies
7/12crypto: atmel-i2c - introduce shared teardown helpers and fix queue flushdrivers/crypto/atmel-ecc.c drivers/crypto/atmel-i2c.c drivers/crypto/atmel-i2c.h+29 -190 replies
8/12crypto: atmel-ecc - switch to module_i2c_driverdrivers/crypto/atmel-ecc.c+1 -120 replies
9/12crypto: atmel-i2c - move shared client allocation logic to coredrivers/crypto/atmel-ecc.c drivers/crypto/atmel-i2c.c drivers/crypto/atmel-i2c.h+53 -480 replies
10/12crypto: atmel-i2c - implement capability-based client selectiondrivers/crypto/atmel-ecc.c drivers/crypto/atmel-i2c.c drivers/crypto/atmel-i2c.h +1 more+17 -30 replies
11/12crypto: atmel-sha204a - integrate into core management trackingdrivers/crypto/atmel-sha204a.c+22 -40 replies
12/12crypto: atmel-sha204a - switch to module_i2c_driverdrivers/crypto/atmel-sha204a.c+1 -120 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.

Read the v4 thread

Cover letter [PATCH v4 00/12] crypto: atmel - introduce shared i2c core client management and capability-based selection framework

This patch series introduces a staged refactoring of the Atmel crypto I2C drivers in preparation for a shared core-based architecture. The goal is to consolidate I2C client management and selection logic into a common atmel-i2c core driver while keeping ECC (ECDH) and SHA204A client drivers functionally separate but interoperating through shared infrastructure.

The series moves existing ECC-specific client tracking into a shared management structure, relocates allocation and selection logic, and introduces capability-based filtering for hardware selection. This allows individual crypto drivers to request hardware clients based on supported features while still benefiting from a unified least-loaded selection strategy.

Subsequent patches extend this base by:
- migrating client management fully into the core driver,
- introducing explicit capability advertisement by each hardware client,
- updating ECC and SHA204A drivers to participate in capability-aware allocation,
- and cleaning up probe/remove paths to ensure consistent lifecycle handling.

No functional behavioral changes are intended at this stage beyond internal refactoring and preparation for future feature expansion. The series is designed to preserve existing crypto functionality while gradually centralizing shared logic in the atmel-i2c core layer, reducing duplication and improving maintainability across all Atmel crypto drivers.

Note, this series is a more elaborated part of a bigger refactoring, sketched out here:
https://sashiko.dev/#/patchset/20260512224349.64621-1-l.rubusch%40gmail.com

---
v3 -> v4:
- sashiko feedback[3]
- fixes and patches reordered
- fix: cover a possible memory leak at deregistration and subsequent reregistration
[3] https://sashiko.dev/#/patchset/20260520155703.23018-1-l.rubusch%40gmail.com

v2 -> v3:
- sashiko feedback[2]
- ecc: reorder setting ready flag in probe()
- i2c: unconditionally call flush in unregister client function, to avoid UAF for multiple devices
- i2c: fixed a sleep-in-atomic bug by moving atmel_i2c_flush_queue() outside the spin_lock section
- sha204a: reorder calls in remove() avoid UAF flagged risk
- sha204a: rephrase commit messages
[2] https://sashiko.dev/#/patchset/20260519204803.17034-1-l.rubusch%40gmail.com

v1 -> v2:
- going over Sashiko feedback[1]
- rephrasing commit messages and titles
- fix: introduce a ready/state flag to address the UAF risk
- fix: add kpp lock and refcnt to impede overwriting global driver struct
- fix: explicitely clearing rng cached buffer in return branch
- unregistering ready state by dedicated function
- reorder Atmel ECC related things and atmel I2C at beginning
- reorder Atmel SHA204a related things behind introduction of cap
- patches dropped: NULL checks in remove functions
- changed to EXPORT_SYMBOL_GPL
- additionally to alloc hw client also migrate freeing it to core driver
[1] https://sashiko.dev/#/patchset/20260517180639.9657-1-l.rubusch%40gmail.com
---
Lothar Rubusch (12):
crypto: atmel-ecc - fix use after free situation
crypto: atmel-ecc - fix multi-device kpp registration
crypto: atmel-sha204a - fix heap info leak on I2C transfer failure
crypto: atmel-ecc - rename driver_data before moving it into atmel-i2c
crypto: atmel - rename atmel_ecc_driver_data to atmel_i2c_client_mgmt
crypto: atmel-i2c - move client management instance into core
crypto: atmel-i2c - introduce shared teardown helpers and fix queue
flush
crypto: atmel-ecc - switch to module_i2c_driver
crypto: atmel-i2c - move shared client allocation logic to core
crypto: atmel-i2c - implement capability-based client selection
crypto: atmel-sha204a - integrate into core management tracking
crypto: atmel-sha204a - switch to module_i2c_driver

 drivers/crypto/atmel-ecc.c     | 177 ++++++++++++++++-----------------
 drivers/crypto/atmel-i2c.c     |  77 ++++++++++++++
 drivers/crypto/atmel-i2c.h     |  18 +++-
 drivers/crypto/atmel-sha204a.c |  48 +++++----
 4 files changed, 210 insertions(+), 110 deletions(-)

base-commit: 49e05bb00f2e8168695f7af4d694c39e1423e8a2

Signature · 1 line
2.39.5