Commit e66effaf authored by Nayna Jain's avatar Nayna Jain Committed by Michael Ellerman

security/integrity: fix pointer to ESL data and its size on pseries

On PowerVM guest, variable data is prefixed with 8 bytes of timestamp.
Extract ESL by stripping off the timestamp before passing to ESL parser.

Fixes: 4b3e71e9 ("integrity/powerpc: Support loading keys from PLPKS")
Cc: stable@vger.kenrnel.org # v6.3
Signed-off-by: default avatarNayna Jain <nayna@linux.ibm.com>
Tested-by: default avatarNageswara R Sastry <rnsastry@linux.ibm.com>
Acked-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20230608120444.382527-1-nayna@linux.ibm.com
parent c8eebc4a
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
#include "keyring_handler.h" #include "keyring_handler.h"
#include "../integrity.h" #include "../integrity.h"
#define extract_esl(db, data, size, offset) \
do { db = data + offset; size = size - offset; } while (0)
/* /*
* Get a certificate list blob from the named secure variable. * Get a certificate list blob from the named secure variable.
* *
...@@ -55,8 +58,9 @@ static __init void *get_cert_list(u8 *key, unsigned long keylen, u64 *size) ...@@ -55,8 +58,9 @@ static __init void *get_cert_list(u8 *key, unsigned long keylen, u64 *size)
*/ */
static int __init load_powerpc_certs(void) static int __init load_powerpc_certs(void)
{ {
void *db = NULL, *dbx = NULL; void *db = NULL, *dbx = NULL, *data = NULL;
u64 dbsize = 0, dbxsize = 0; u64 dsize = 0;
u64 offset = 0;
int rc = 0; int rc = 0;
ssize_t len; ssize_t len;
char buf[32]; char buf[32];
...@@ -74,38 +78,46 @@ static int __init load_powerpc_certs(void) ...@@ -74,38 +78,46 @@ static int __init load_powerpc_certs(void)
return -ENODEV; return -ENODEV;
} }
if (strcmp("ibm,plpks-sb-v1", buf) == 0)
/* PLPKS authenticated variables ESL data is prefixed with 8 bytes of timestamp */
offset = 8;
/* /*
* Get db, and dbx. They might not exist, so it isn't an error if we * Get db, and dbx. They might not exist, so it isn't an error if we
* can't get them. * can't get them.
*/ */
db = get_cert_list("db", 3, &dbsize); data = get_cert_list("db", 3, &dsize);
if (!db) { if (!data) {
pr_info("Couldn't get db list from firmware\n"); pr_info("Couldn't get db list from firmware\n");
} else if (IS_ERR(db)) { } else if (IS_ERR(data)) {
rc = PTR_ERR(db); rc = PTR_ERR(data);
pr_err("Error reading db from firmware: %d\n", rc); pr_err("Error reading db from firmware: %d\n", rc);
return rc; return rc;
} else { } else {
rc = parse_efi_signature_list("powerpc:db", db, dbsize, extract_esl(db, data, dsize, offset);
rc = parse_efi_signature_list("powerpc:db", db, dsize,
get_handler_for_db); get_handler_for_db);
if (rc) if (rc)
pr_err("Couldn't parse db signatures: %d\n", rc); pr_err("Couldn't parse db signatures: %d\n", rc);
kfree(db); kfree(data);
} }
dbx = get_cert_list("dbx", 4, &dbxsize); data = get_cert_list("dbx", 4, &dsize);
if (!dbx) { if (!data) {
pr_info("Couldn't get dbx list from firmware\n"); pr_info("Couldn't get dbx list from firmware\n");
} else if (IS_ERR(dbx)) { } else if (IS_ERR(data)) {
rc = PTR_ERR(dbx); rc = PTR_ERR(data);
pr_err("Error reading dbx from firmware: %d\n", rc); pr_err("Error reading dbx from firmware: %d\n", rc);
return rc; return rc;
} else { } else {
rc = parse_efi_signature_list("powerpc:dbx", dbx, dbxsize, extract_esl(dbx, data, dsize, offset);
rc = parse_efi_signature_list("powerpc:dbx", dbx, dsize,
get_handler_for_dbx); get_handler_for_dbx);
if (rc) if (rc)
pr_err("Couldn't parse dbx signatures: %d\n", rc); pr_err("Couldn't parse dbx signatures: %d\n", rc);
kfree(dbx); kfree(data);
} }
return rc; return 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