Re: [PATCH v3 22/24] powerpc/pseries: Implement secvars for dynamic secure boot

From
Stefan Berger <stefanb@linux.ibm.com>
Date
2023-01-18 13:37:25
Also in
linux-integrity, lkml
Reply to
Andrew Donnellan, 2023-01-18

On 1/18/23 01:10, Andrew Donnellan wrote:
quoted hunk ↗ jump to hunk
+
+// PLPKS dynamic secure boot doesn't give us a format string in the same way OPAL does.
+// Instead, report the format using the SB_VERSION variable in the keystore.
+static ssize_t plpks_secvar_format(char *buf)
Ideally there would be a size_t accompanying this buffer...
quoted hunk ↗ jump to hunk
+{
+	struct plpks_var var = {0};
+	ssize_t ret;
+
+	var.component = NULL;
+	// Only the signed variables have null bytes in their names, this one doesn't
+	var.name = "SB_VERSION";
+	var.namelen = 10;
+	var.datalen = 1;
+	var.data = kzalloc(1, GFP_KERNEL);
NULL pointer check?
quoted hunk ↗ jump to hunk
+
+	// Unlike the other vars, SB_VERSION is owned by firmware instead of the OS
+	ret = plpks_read_fw_var(&var);
+	if (ret) {
+		if (ret == -ENOENT) {
+			ret = snprintf(buf, SECVAR_MAX_FORMAT_LEN, "ibm,plpks-sb-unknown");
+		} else {
+			pr_err("Error %ld reading SB_VERSION from firmware\n", ret);
+			ret = -EIO;
+		}
+		goto err;
+	}
+
+	// This string is made up by us - the hypervisor doesn't provide us
+	// with a format string in the way that OPAL firmware does. Hypervisor
+	// defines SB_VERSION as a "1 byte unsigned integer value".
+	ret = snprintf(buf, SECVAR_MAX_FORMAT_LEN, "ibm,plpks-sb-v%hhu", var.data[0]);
+
+err:
+	kfree(var.data);
+	return ret;
+}
+
Thread (36 messages) 36 messages, 5 authors, last reply 2023-01-20
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help