From: Greg Joyce <redacted>
Changelog v3a:
- No code changes, but per reviewer requests, adding additional
mailing lists(keyring, EFI) for wider review.
Architectural neutral functions have been defined for accessing
architecture specific variable store. The neutral functions are
defined as weak so that they may be superseded by platform
specific versions. The functions have been desigined so that
they can support a large range of platforms/architectures.
PowerPC/pseries versions of these functions provide read/write access
to the non-volatile PLPKS data store.
This functionality allows kernel code such as the block SED opal
driver to store authentication keys in a secure permanent store.
Greg Joyce (2):
lib: define generic accessor functions for arch specific keystore
powerpc/pseries: Override lib/arch_vars.c functions
arch/powerpc/platforms/pseries/Makefile | 1 +
.../platforms/pseries/plpks_arch_ops.c | 167 ++++++++++++++++++
include/linux/arch_vars.h | 23 +++
lib/Makefile | 2 +-
lib/arch_vars.c | 25 +++
5 files changed, 217 insertions(+), 1 deletion(-)
create mode 100644 arch/powerpc/platforms/pseries/plpks_arch_ops.c
create mode 100644 include/linux/arch_vars.h
create mode 100644 lib/arch_vars.c
Signed-off-by: Greg Joyce <redacted>
base-commit: ff6992735ade75aae3e35d16b17da1008d753d28
--
2.27.0
From: Greg Joyce <redacted>
Self Encrypting Drives(SED) make use of POWER LPAR Platform KeyStore
for storing its variables. Thus the block subsystem needs to access
PowerPC specific functions to read/write objects in PLPKS.
Override the default implementations in lib/arch_vars.c file with
PowerPC specific versions.
Signed-off-by: Greg Joyce <redacted>
---
arch/powerpc/platforms/pseries/Makefile | 1 +
.../platforms/pseries/plpks_arch_ops.c | 167 ++++++++++++++++++
2 files changed, 168 insertions(+)
create mode 100644 arch/powerpc/platforms/pseries/plpks_arch_ops.c
From: Greg Joyce <redacted>
Generic kernel subsystems may rely on platform specific persistent
KeyStore to store objects containing sensitive key material. In such case,
they need to access architecture specific functions to perform read/write
operations on these variables.
Define the generic variable read/write prototypes to be implemented by
architecture specific versions. The default(weak) implementations of
these prototypes return -EOPNOTSUPP unless overridden by architecture
versions.
Signed-off-by: Greg Joyce <redacted>
---
include/linux/arch_vars.h | 23 +++++++++++++++++++++++
lib/Makefile | 2 +-
lib/arch_vars.c | 25 +++++++++++++++++++++++++
3 files changed, 49 insertions(+), 1 deletion(-)
create mode 100644 include/linux/arch_vars.h
create mode 100644 lib/arch_vars.c
@@ -0,0 +1,23 @@+/* SPDX-License-Identifier: GPL-2.0 */+/*+*Platformvariableopearations.+*+*Copyright(C)2022IBMCorporation+*+*Thesearetheaccessorfunctions(read/write)forarchitecturespecific+*variables.Specificarchitecturescanprovideoverrides.+*+*/++#include<linux/kernel.h>++enumarch_variable_type{+ARCH_VAR_OPAL_KEY=0,/* SED Opal Authentication Key */+ARCH_VAR_OTHER=1,/* Other type of variable */+ARCH_VAR_MAX=1,/* Maximum type value */+};++intarch_read_variable(enumarch_variable_typetype,char*varname,+void*varbuf,u_int*varlen);+intarch_write_variable(enumarch_variable_typetype,char*varname,+void*varbuf,u_intvarlen);
Le 08/08/2022 à 17:43, gjoyce@linux.vnet.ibm.com a écrit :
quoted hunk
From: Greg Joyce <redacted>
Generic kernel subsystems may rely on platform specific persistent
KeyStore to store objects containing sensitive key material. In such case,
they need to access architecture specific functions to perform read/write
operations on these variables.
Define the generic variable read/write prototypes to be implemented by
architecture specific versions. The default(weak) implementations of
these prototypes return -EOPNOTSUPP unless overridden by architecture
versions.
Signed-off-by: Greg Joyce <redacted>
---
include/linux/arch_vars.h | 23 +++++++++++++++++++++++
lib/Makefile | 2 +-
lib/arch_vars.c | 25 +++++++++++++++++++++++++
3 files changed, 49 insertions(+), 1 deletion(-)
create mode 100644 include/linux/arch_vars.h
create mode 100644 lib/arch_vars.c
Is it platform specific or architecture specific ?
+ *
+ * Copyright (C) 2022 IBM Corporation
+ *
+ * These are the accessor functions (read/write) for architecture specific
+ * variables. Specific architectures can provide overrides.
"variables" is a very generic word which I think doesn't match what you
want to do.
For me "variables" are local variables and global variables in a C file.
Here it seems to be something completely different hence the name is
really meaningfull and misleading.
arch_variable_type ? What's that ? variable types are char, short, long,
long long, etc ...
+ ARCH_VAR_OPAL_KEY = 0, /* SED Opal Authentication Key */
+ ARCH_VAR_OTHER = 1, /* Other type of variable */
+ ARCH_VAR_MAX = 1, /* Maximum type value */
+};
Why the hell do you need an enum for two values only ?
Le 08/08/2022 à 17:43, gjoyce@linux.vnet.ibm.com a écrit :
quoted hunk
From: Greg Joyce <redacted>
Self Encrypting Drives(SED) make use of POWER LPAR Platform KeyStore
for storing its variables. Thus the block subsystem needs to access
PowerPC specific functions to read/write objects in PLPKS.
Override the default implementations in lib/arch_vars.c file with
PowerPC specific versions.
Signed-off-by: Greg Joyce <redacted>
---
arch/powerpc/platforms/pseries/Makefile | 1 +
.../platforms/pseries/plpks_arch_ops.c | 167 ++++++++++++++++++
2 files changed, 168 insertions(+)
create mode 100644 arch/powerpc/platforms/pseries/plpks_arch_ops.c
From: Michal Suchánek <hidden> Date: 2022-08-08 16:42:36
On Mon, Aug 08, 2022 at 04:31:06PM +0000, Christophe Leroy wrote:
Le 08/08/2022 à 17:43, gjoyce@linux.vnet.ibm.com a écrit :
quoted
From: Greg Joyce <redacted>
Generic kernel subsystems may rely on platform specific persistent
KeyStore to store objects containing sensitive key material. In such case,
they need to access architecture specific functions to perform read/write
operations on these variables.
Define the generic variable read/write prototypes to be implemented by
architecture specific versions. The default(weak) implementations of
these prototypes return -EOPNOTSUPP unless overridden by architecture
versions.
Signed-off-by: Greg Joyce <redacted>
---
include/linux/arch_vars.h | 23 +++++++++++++++++++++++
lib/Makefile | 2 +-
lib/arch_vars.c | 25 +++++++++++++++++++++++++
3 files changed, 49 insertions(+), 1 deletion(-)
create mode 100644 include/linux/arch_vars.h
create mode 100644 lib/arch_vars.c
Is it platform specific or architecture specific ?
quoted
+ *
+ * Copyright (C) 2022 IBM Corporation
+ *
+ * These are the accessor functions (read/write) for architecture specific
+ * variables. Specific architectures can provide overrides.
"variables" is a very generic word which I think doesn't match what you
want to do.
For me "variables" are local variables and global variables in a C file.
Here it seems to be something completely different hence the name is
really meaningfull and misleading.
arch_variable_type ? What's that ? variable types are char, short, long,
long long, etc ...
quoted
+ ARCH_VAR_OPAL_KEY = 0, /* SED Opal Authentication Key */
+ ARCH_VAR_OTHER = 1, /* Other type of variable */
+ ARCH_VAR_MAX = 1, /* Maximum type value */
+};
Why the hell do you need an enum for two values only ?
+ *
+ * Copyright (C) 2022 IBM Corporation
+ *
+ * These are the accessor functions (read/write) for architecture specific
+ * variables. Specific architectures can provide overrides.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/arch_vars.h>
+
+int __weak arch_read_variable(enum arch_variable_type type, char *varname,
+ void *varbuf, u_int *varlen)
Sorry, to read a variable, I use READ_ONCE or I read it directly.
This is supposed to be used for things like the EFI variables and the
already existing powernv secure variables.
Nonetheless, without adding the plumbing for the existing
implementations it is not clear what it's doing, and the interface is
agruably meaningless.
Hence I would either suggest to provide the plumbing necessary for
existing (secure) variable implementations to make use of the interface,
or use private implementations like all the existing platforms do
without exposing the values in any generic way, and leave that to
somebody who is comfortable with designing a working general inteface
for this.
Thanks
Michal