[PATCH 2/2] MACsec: Explicitly clear MSK and CAK

Xiaoyi Suo 18102059357 at 163.com
Sun Nov 22 16:12:00 PST 2026


ieee802_1x_notify_create_actor() clears the EAP MSK and the CAK built
from it on the error path, then frees them. Nothing reads them after the
clear. So the compiler can drop it, and GCC 13.3 and Clang 18 do drop it
at -O2. The MSK is still in the heap block when free() is called.

Use forced_memzero() so the key material is cleared before the block goes
back to the allocator.

This is a hardening change. It removes the extra copy that stays in
memory. It does not fix a known read-back path.

Signed-off-by: Xiaoyi Suo <18102059357 at 163.com>
---
 wpa_supplicant/wpas_kay.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/wpa_supplicant/wpas_kay.c b/wpa_supplicant/wpas_kay.c
index 7893a39..1033350 100644
--- a/wpa_supplicant/wpas_kay.c
+++ b/wpa_supplicant/wpas_kay.c
@@ -361,12 +361,12 @@ void * ieee802_1x_notify_create_actor(struct wpa_supplicant *wpa_s,
 
 fail:
 	if (msk) {
-		os_memset(msk, 0, sizeof(*msk));
+		forced_memzero(msk, sizeof(*msk));
 		os_free(msk);
 	}
 	os_free(ckn);
 	if (cak) {
-		os_memset(cak, 0, sizeof(*cak));
+		forced_memzero(cak, sizeof(*cak));
 		os_free(cak);
 	}
 
-- 
2.55.0.windows.5




More information about the Hostap mailing list