Skip to content

crypto: Add __cleanup functions for zeroizing aes_cmac_key & aes_cmac_ctx

Thomas Huth linux-bluetooth linux-cifs linux-crypto linux-wireless lkml netdev 2 versions – NAK

Status from this message: Nak, we don't like the auto-cleanup stuff in networking.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest6 patches 7 repliesNAK
  2. v16 patches 7 repliesSuperseded

Changes in v2 from the cover letter

- Update comments and positions of the functions in the 1st patch
- Also clear tmp[] in the bluetooth patch (the patch is pointless otherwise)

Patches in v2

#Subject and filesSizeRepliesApplied
1/6crypto: Provide wrapper functions for zeroizing aes_cmac_key and aes_cmac_ctxinclude/crypto/aes-cbc-macs.h+34 -00 replies
2/6smb: clear the aes_cmac_key and aes_cmac_ctx when donefs/smb/client/smb2transport.c fs/smb/server/auth.c+3 -33 replies
3/6net/tcp-ao: clear the aes_cmac_key when donenet/ipv4/tcp_ao.c+1 -12 replies
4/6Bluetooth: SMP: clear the aes_cmac_key when donenet/bluetooth/smp.c+2 -10 replies
5/6lib/crypto: aes: Use __cleanup() for aes_cmac_key instead of memzero_explicit()lib/crypto/aes.c+1 -20 replies
6/6mac80211: fils_aead: Use __cleanup() for aes_cmac_key instead of memzero_explicit()net/mac80211/fils_aead.c+1 -21 reply

Reviews trailers per patch

2 of 6 patches have a Reviewed-by or Acked-by.

PatchJohannes BergNamjae Jeon
1/6
2/6A-b
3/6
4/6
5/6
6/6A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/6] crypto: Add __cleanup functions for zeroizing aes_cmac_key & aes_cmac_ctx

Code that uses AES-CMAC might need to zeroize their local aes_cmac_key and/or aes_cmac_ctx structures after use to avoid leaking sensitive material on the stack.

The first patch introduces an aes_cmac_zeroize_key() and an aes_cmac_zeroize_ctx() helper function that can be used with __cleanup() to automatically clear the key and context when they go out of scope.

Patches 2 - 4 add the __cleanup markers to spots in the code that missed to clean up the structures so far.

The final two patches are just cosmetics and change some memzero_explicit() calls to use the __cleanup() way instead.

Note: There are more spots in the smb, tcp-ao and bluetooth code that need some zeroization of sensitive data on the stack. I will tackle those in later patches, this series here focuses on the new __cleanup wrappers.

v2:
- Update comments and positions of the functions in the 1st patch
- Also clear tmp[] in the bluetooth patch (the patch is pointless otherwise)

Thomas Huth (6):
crypto: Provide wrapper functions for zeroizing aes_cmac_key and
aes_cmac_ctx
smb: clear the aes_cmac_key and aes_cmac_ctx when done net/tcp-ao: clear the aes_cmac_key when done
Bluetooth: SMP: clear the aes_cmac_key when done lib/crypto: aes: Use _cleanup() for aes_cmac_key instead of
memzero_explicit()
mac80211: fils_aead: Use _cleanup for aes_cmac_key instead of
memzero_explicit

 fs/smb/client/smb2transport.c |  4 ++--
 fs/smb/server/auth.c          |  2 +-
 include/crypto/aes-cbc-macs.h | 34 ++++++++++++++++++++++++++++++++++
 lib/crypto/aes.c              |  3 +--
 net/bluetooth/smp.c           |  3 ++-
 net/ipv4/tcp_ao.c             |  2 +-
 net/mac80211/fils_aead.c      |  3 +--
 7 files changed, 42 insertions(+), 9 deletions(-)
Signature · 1 line
2.55.0