CVE-2026-138921: crypto: caam - fix double-free in caam_rsa_set_priv_key_form()
In the Linux kernel, the following vulnerability has been resolved:
crypto: caam - fix double-free in caamrsasetprivkeyform()
caamrsasetprivkeyform() frees the partially allocated key components (p, q, tmp1, tmp2, dp, dq) with kfreesensitive() on its error path, but does not set those pointers to NULL afterward.
When the function returns an error, caamrsasetprivkey() jumps to its err label and calls caamrsafreekey(), which frees all of those same pointers again, resulting in a double-free.
This is reachable when the allocation of q, tmp1, tmp2, dp, dq or qinv fails, e.g. under memory pressure, or for a malformed key whose CRT members decode to zero length and make caamreadrsacrt() return NULL.
Set each pointer to NULL right after freeing it so that the subsequent caamrsafreekey() call becomes a no-op for the already-freed fields.
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
In caam_rsa_set_priv_key_form(), set each key-component pointer to NULL immediately after freeing it with kfree_sensitive(), so caam_rsa_free_key() does not free it again.