[PATCH v3 3/6] keys/trusted_keys: clear sensitive PKWM buffers
From: Srish Srinivasan
Date: Sat Oct 17 2026 - 03:51:05 EST
The input buffer to PKWM seal and the output buffer from PKWM unseal
contain plaintext trusted-key payload data. Freeing these buffers with
kfree(), without wiping the contents, can leave sensitive key material
in memory.
Use kfree_sensitive() to wipe the sensitive key material when freeing
these buffers.
Fixes: c99fcb0d735b ("keys/trusted_keys: establish PKWM as a trusted source")
Cc: stable@xxxxxxxxxxxxxxx # 7.0
Signed-off-by: Srish Srinivasan <ssrish@xxxxxxxxxxxxx>
Reviewed-by: Nayna Jain <nayna@xxxxxxxxxxxxx>
Tested-by: R Nageswara Sastry <rnsastry@xxxxxxxxxxxxx>
Reviewed-by: Jarkko Sakkinen <jarkko@xxxxxxxxxx>
---
security/keys/trusted-keys/trusted_pkwm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/security/keys/trusted-keys/trusted_pkwm.c b/security/keys/trusted-keys/trusted_pkwm.c
index 633a7674d065..6774557f818a 100644
--- a/security/keys/trusted-keys/trusted_pkwm.c
+++ b/security/keys/trusted-keys/trusted_pkwm.c
@@ -118,7 +118,7 @@ static int trusted_pkwm_seal(struct trusted_key_payload *p, char *datablob)
pr_err("Wrapping of payload key failed: %d\n", rc);
}
- kfree(input_buf);
+ kfree_sensitive(input_buf);
kfree(output_buf);
out:
@@ -153,7 +153,7 @@ static int trusted_pkwm_unseal(struct trusted_key_payload *p, char *datablob)
}
kfree(input_buf);
- kfree(output_buf);
+ kfree_sensitive(output_buf);
return rc;
}
--
2.52.0