nvme-fabrics: use kfree_sensitive() for DHCHAP secrets
PATCH 1/1 nvme-fabrics: use kfree_sensitive() for DHCHAP secrets
The DHCHAP secrets (dhchap_secret and dhchap_ctrl_secret) contain authentication key material for NVMe-oF. Use kfree_sensitive() instead of kfree() in nvmf_free_options() to ensure secrets are zeroed before the memory is freed, preventing recovery from freed pages.
--- drivers/nvme/host/fabrics.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nvme/host/fabrics.c +2 -2
@@ -1283,22 +1283,22 @@ void nvmf_free_options(struct nvmf_ctrl_options *opts) {nvmf_host_put (opts->host);key_put (opts->keyring);key_put (opts->tls_key);kfree (opts->transport);kfree (opts->traddr);kfree (opts->trsvcid);kfree (opts->subsysnqn);kfree (opts->host_traddr);kfree (opts->host_iface); -kfree (opts->dhchap_secret); -kfree (opts->dhchap_ctrl_secret); +kfree_sensitive (opts->dhchap_secret); +kfree_sensitive (opts->dhchap_ctrl_secret);kfree (opts); }EXPORT_SYMBOL_GPL (nvmf_free_options);#define NVMF_REQUIRED_OPTS (NVMF_OPT_TRANSPORT | NVMF_OPT_NQN)#define NVMF_ALLOWED_OPTS (NVMF_OPT_QUEUE_SIZE | NVMF_OPT_NR_IO_QUEUES | \ NVMF_OPT_KATO | NVMF_OPT_HOSTNQN | \ NVMF_OPT_HOST_ID | NVMF_OPT_DUP_CONNECT |\ NVMF_OPT_DISABLE_SQFLOW | NVMF_OPT_DISCOVERY |\ NVMF_OPT_FAIL_FAST_TMO | NVMF_OPT_DHCHAP_SECRET |\
Signature · 1 line
2.47.3
Quoted 4 lines · Daniel Hodges
The DHCHAP secrets (
dhchap_secretanddhchap_ctrl_secret) contain authentication key material for NVMe-oF. Usekfree_sensitive()instead ofkfree()innvmf_free_options()to ensure secrets are zeroed before the memory is freed, preventing recovery from freed pages.
Looks good:
Quoted 4 lines · Daniel Hodges
The DHCHAP secrets (
dhchap_secretanddhchap_ctrl_secret) contain authentication key material for NVMe-oF. Usekfree_sensitive()instead ofkfree()innvmf_free_options()to ensure secrets are zeroed before the memory is freed, preventing recovery from freed pages.
Thanks, applied to nvme-7.0.