From: Greg Joyce <redacted>
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.
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>
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);
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-01 13:40:28
Hello,
On Mon, Aug 01, 2022 at 07:34:25AM -0500, gjoyce@linux.vnet.ibm.com wrote:
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
@@ -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);
Doesn't EFI already have some variables?
And even powernv?
Shouldn't this generalize the already existing variables?
Or move to powerpc and at least generalize the powerpc ones?
Thanks
Michal
Hello,
On Mon, Aug 01, 2022 at 07:34:25AM -0500, gjoyce@linux.vnet.ibm.com wrote:
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
@@ -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);
Doesn't EFI already have some variables?
And even powernv?
Shouldn't this generalize the already existing variables?
Or move to powerpc and at least generalize the powerpc ones?
Yes, EFI and PowerNV do have variables, but I am not exactly clear about
your reference to them in this context. What do you mean by generalize
already existing variables ?
This interface is actually generalizing calls to access platform
specific keystores. It is explained in cover letter that this patch is
defining generic interface and these are default implementations which
needs to be overridden by arch specific versions. For PowerVM PLPAR
Platform KeyStore, the arch specific version is implemented in Patch 2.
Access to EFI variables should be implemented by EFI arch specific
interface and PowerNV will have to do the same if it needs to.
Hope it helps.
Thanks & Regards,
- Nayna
From: Michal Suchánek <hidden> Date: 2022-08-01 20:24:07
On Mon, Aug 01, 2022 at 03:45:45PM -0400, Nayna wrote:
On 8/1/22 09:40, Michal Suchánek wrote:
quoted
Hello,
On Mon, Aug 01, 2022 at 07:34:25AM -0500, gjoyce@linux.vnet.ibm.com wrote:
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
@@ -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);
Doesn't EFI already have some variables?
And even powernv?
Shouldn't this generalize the already existing variables?
Or move to powerpc and at least generalize the powerpc ones?
Yes, EFI and PowerNV do have variables, but I am not exactly clear about
your reference to them in this context. What do you mean by generalize
already existing variables ?
This interface is actually generalizing calls to access platform specific
keystores. It is explained in cover letter that this patch is defining
generic interface and these are default implementations which needs to be
overridden by arch specific versions. For PowerVM PLPAR Platform KeyStore,
the arch specific version is implemented in Patch 2.
For powervm, not powernv.
If it's not generic enough to cover even powerpc-specific keystores does
such generalization even need to exist?
Access to EFI variables should be implemented by EFI arch specific interface
and PowerNV will have to do the same if it needs to.
If such generic interface is desirable it should cover the existing
architectures I think. Otherwise how can you tell if it's usable there?
Thanks
Michal
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2022-08-02 02:59:43
Hi Greg,
gjoyce@linux.vnet.ibm.com writes:
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
I don't think "arch" is the right level of abstraction here.
There isn't a standard way to get these variables across a given arch,
they're not defined in the architecture specification etc.
As demonstrated in your patch 2, on powerpc they are coming from a
platform level pseudo device (provided by the PowerVM hypervisor). But
they would come from elsewhere on a bare metal system.
And you could imagine other architectures could support multiple ways to
retrieve these kind of variables from various different places, possibly
more than one place on a given system.
So I think at least you want a way for any device to register itself as
able to provide these variables. Possibly with a chain of handlers,
something like the sys_off_handlers, or maybe there only ever needs to
be one provider, the way pm_power_off (used to) work.
Looking at your patch to block/sed-opal.c:
https://lore.kernel.org/all/20220718210156.1535955-4-gjoyce@linux.vnet.ibm.com/
It seems like the calls to these arch routines are closely tied to calls
to the keyring API. Should this functionality be part of the keyring
API?
At a mininmum I think you need to get much wider review on something
like this. So I'd suggest the keyring folks and as Michal pointed out,
this seems a bit like EFI variables so it would be good to Cc the
EFI/EFI variable folks.
cheers
Michael and Michal,
On Tue, 2022-08-02 at 12:59 +1000, Michael Ellerman wrote:
I don't think "arch" is the right level of abstraction here.
There isn't a standard way to get these variables across a given
arch,
they're not defined in the architecture specification etc.
As demonstrated in your patch 2, on powerpc they are coming from a
platform level pseudo device (provided by the PowerVM hypervisor).
But
they would come from elsewhere on a bare metal system.
I'm open to something other than "arch_" if that causes confusion.
Maybe "plat_"?
And you could imagine other architectures could support multiple ways
to
retrieve these kind of variables from various different places,
possibly
more than one place on a given system.
Agreed, and that's why an architecture or platform can override the
functions. The first parameter also allows for further distinction of
how the data could be interpreted, including in multiple ways as you
suggest.
I wanted to allow for different types of persistent storage. For
instance you could have a platform that used a NAND deice for permanent
storage that could still use the API as proposed.
So I think at least you want a way for any device to register itself
as
able to provide these variables. Possibly with a chain of handlers,
something like the sys_off_handlers, or maybe there only ever needs
to
be one provider, the way pm_power_off (used to) work.
I did look at some of the other ways of dynamically registering
functions but most of the exisiting examples are centered around a
specific device entity which is not the case here. The functionailty is
pretty simple so I was hoping to keep the API simple as well.
The sys_off_handler functions certainly provide a good way of
registering for asynchronous notifications but for this purpose we need
synchronous functions that possibly return data. Many of the pci
functions end up in platform specific code but they use information
from struct pci_dev to route the call to the appropriate place.
Those calls are just using the API to read/write named variables that
happen to be keys in this case. I was envisioning that there may be
uses other than SED for persistent key/values.
At a mininmum I think you need to get much wider review on something
like this. So I'd suggest the keyring folks and as Michal pointed
out,
this seems a bit like EFI variables so it would be good to Cc the
EFI/EFI variable folks.
The keyring folks were on the original SED patchset review and I did
incorporate a good comment involving use of keyrings. I will copy them
again (as well as EFI folks) for the next update.
-Greg
Doesn't EFI already have some variables?
And even powernv?
Shouldn't this generalize the already existing variables?
Or move to powerpc and at least generalize the powerpc ones?
Yes, EFI and PowerNV do have variables, but I am not exactly clear
about
your reference to them in this context. What do you mean by
generalize
already existing variables ?
This interface is actually generalizing calls to access platform
specific
keystores. It is explained in cover letter that this patch is
defining
generic interface and these are default implementations which needs
to be
overridden by arch specific versions. For PowerVM PLPAR Platform
KeyStore,
the arch specific version is implemented in Patch 2.
For powervm, not powernv.
If it's not generic enough to cover even powerpc-specific keystores
does
such generalization even need to exist?
I believe that the interface is generic enough to cover most if not all
keystores. However, we're just implementing a PowerVM version since
that is our mandate.
quoted
Access to EFI variables should be implemented by EFI arch specific
interface
and PowerNV will have to do the same if it needs to.
If such generic interface is desirable it should cover the existing
architectures I think. Otherwise how can you tell if it's usable
there?
Are you suggesting that we implement architecture specific
implementations for every architecture supported by Linux? I'm afraid
that we don't have the time (or skills) to do that. The intent is to
provide the "weak" versions of the interface functions so that they can
be overridden as folks have the time or inclination to provide them for
other architectures.
-Greg