Commit 1f622f3f authored by Nayna Jain's avatar Nayna Jain Committed by Michael Ellerman

powerpc/pseries: fix plpks_read_var() code for different consumers

Even though plpks_read_var() is currently called to read variables
owned by different consumers, it internally supports only OS consumer.

Fix plpks_read_var() to handle different consumers correctly.

Fixes: 2454a7af ("powerpc/pseries: define driver for Platform KeyStore")
Signed-off-by: default avatarNayna Jain <nayna@linux.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20221106205839.600442-7-nayna@linux.ibm.com
parent 212dd5cf
...@@ -354,22 +354,24 @@ static int plpks_read_var(u8 consumer, struct plpks_var *var) ...@@ -354,22 +354,24 @@ static int plpks_read_var(u8 consumer, struct plpks_var *var)
{ {
unsigned long retbuf[PLPAR_HCALL_BUFSIZE] = { 0 }; unsigned long retbuf[PLPAR_HCALL_BUFSIZE] = { 0 };
struct plpks_auth *auth; struct plpks_auth *auth;
struct label *label; struct label *label = NULL;
u8 *output; u8 *output;
int rc; int rc;
if (var->namelen > MAX_NAME_SIZE) if (var->namelen > MAX_NAME_SIZE)
return -EINVAL; return -EINVAL;
auth = construct_auth(PKS_OS_OWNER); auth = construct_auth(consumer);
if (IS_ERR(auth)) if (IS_ERR(auth))
return PTR_ERR(auth); return PTR_ERR(auth);
label = construct_label(var->component, var->os, var->name, if (consumer == PKS_OS_OWNER) {
var->namelen); label = construct_label(var->component, var->os, var->name,
if (IS_ERR(label)) { var->namelen);
rc = PTR_ERR(label); if (IS_ERR(label)) {
goto out_free_auth; rc = PTR_ERR(label);
goto out_free_auth;
}
} }
output = kzalloc(maxobjsize, GFP_KERNEL); output = kzalloc(maxobjsize, GFP_KERNEL);
...@@ -378,9 +380,15 @@ static int plpks_read_var(u8 consumer, struct plpks_var *var) ...@@ -378,9 +380,15 @@ static int plpks_read_var(u8 consumer, struct plpks_var *var)
goto out_free_label; goto out_free_label;
} }
rc = plpar_hcall(H_PKS_READ_OBJECT, retbuf, virt_to_phys(auth), if (consumer == PKS_OS_OWNER)
virt_to_phys(label), label->size, virt_to_phys(output), rc = plpar_hcall(H_PKS_READ_OBJECT, retbuf, virt_to_phys(auth),
maxobjsize); virt_to_phys(label), label->size, virt_to_phys(output),
maxobjsize);
else
rc = plpar_hcall(H_PKS_READ_OBJECT, retbuf, virt_to_phys(auth),
virt_to_phys(var->name), var->namelen, virt_to_phys(output),
maxobjsize);
if (rc != H_SUCCESS) { if (rc != H_SUCCESS) {
rc = pseries_status_to_err(rc); rc = pseries_status_to_err(rc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment