[PATCH 0/2] Explicitly clear PTK derivation and MSK/CAK buffers

Xiaoyi Suo 18102059357 at 163.com
Mon Nov 23 00:19:36 PST 2026


This series changes two places that clear keys with os_memset().
Nothing reads the buffers after the clear, so the compiler can drop the
clear. GCC 13.3 and Clang 18 do drop it at -O2.

1/2 wpa_pmk_to_ptk(): tmp[] holds the new KCK, KEK, TK and KDK. data[]
holds the addresses, the nonces, and the optional Z value (DHss for
802.1X auth in Authentication frames, or the DPP shared secret). After
the clear, both buffers still hold their data. The same file already
uses forced_memzero() for the same kind of buffer in pasn_pmk_to_ptk()
and wpa_pmk_r1_to_ptk().

2/2 ieee802_1x_notify_create_actor(): the EAP MSK and the CAK built from
it are cleared on the error path, then freed. The compiler drops that
clear too. The MSK is still in the heap block when free() is called.

Both patches are hardening. They remove the extra copy that stays in
memory. They do not fix a known read-back path.

Xiaoyi Suo (2):
  WPA: Explicitly clear PTK derivation buffers
  MACsec: Explicitly clear MSK and CAK

 src/common/wpa_common.c   | 4 ++--
 wpa_supplicant/wpas_kay.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

-- 
2.55.0.windows.5




More information about the Hostap mailing list