PLPKS wrapping key generation, object wrapping, and object unwrapping use
authentication buffers that contain passwords. An object unwrapping failure
also frees an output buffer that may contain sensitive data. Freeing these
buffers with kfree(), without wiping the contents, can leave sensitive data
in memory.
Use kfree_sensitive() to wipe the buffers when freeing them.
Fixes: 133aa79e211d ("pseries/plpks: add HCALLs for PowerVM Key Wrapping
Module")
Cc: [email protected] # 7.0
Signed-off-by: Srish Srinivasan <[email protected]>
Reviewed-by: Nayna Jain <[email protected]>
Tested-by: R Nageswara Sastry <[email protected]>
---
arch/powerpc/platforms/pseries/plpks.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/plpks.c
b/arch/powerpc/platforms/pseries/plpks.c
index 8dbf85e9714c..17a73a04d45b 100644
--- a/arch/powerpc/platforms/pseries/plpks.c
+++ b/arch/powerpc/platforms/pseries/plpks.c
@@ -975,7 +975,7 @@ int plpks_gen_wrapping_key(void)
kfree(label);
out:
- kfree(auth);
+ kfree_sensitive(auth);
return rc;
}
EXPORT_SYMBOL_GPL(plpks_gen_wrapping_key);
@@ -1100,7 +1100,7 @@ int plpks_wrap_object(u8 **input_buf, u32 input_len, u16
wrap_flags,
out_free_label:
kfree(label);
out:
- kfree(auth);
+ kfree_sensitive(auth);
return rc;
}
EXPORT_SYMBOL_GPL(plpks_wrap_object);
@@ -1177,14 +1177,14 @@ int plpks_unwrap_object(u8 **input_buf, u32 input_len,
u8 **output_buf,
if (rc) {
pr_err("H_PKS_UNWRAP_OBJECT failed. pseries_status=%d, rc=%d",
pseries_status, rc);
- kfree(*output_buf);
+ kfree_sensitive(*output_buf);
*output_buf = NULL;
} else {
*output_len = retbuf[1];
}
out:
- kfree(auth);
+ kfree_sensitive(auth);
return rc;
}
EXPORT_SYMBOL_GPL(plpks_unwrap_object);
--
2.52.0