generic and PowerPC SED Opal keystore
Subsystems (3)
v8 cover generic and PowerPC SED Opal keystore
From: Greg Joyce <[email protected]>
This patchset has gone through numerous rounds of review and all comments/suggetions have been addressed. The reviews have covered all relevant areas including reviews by block and keyring developers as well as the SED Opal maintainer.
TCG SED Opal is a specification from The Trusted Computing Group that allows self encrypting storage devices (SED) to be locked at power on and require an authentication key to unlock the drive.
PowerPC/pseries versions of key functions provide read/write access to SED Opal keys in the PLPKS keystore.
The SED block driver has been modified to read the SED Opal keystore to populate a key in the SED Opal keyring. Changes to the SED Opal key will be written to the SED Opal keystore.
Changelog
v8: - rebased to 6.6-rc4
- fixed issues using clang (thanks Nathan Chancellor and Nick Desaulniers)
- fixed crash if PLPKS is not present for pseries (thanks Michael Ellerman)
v7: - rebased to for-6.5/block
v6: - squashed two commits (suggested by Andrew Donnellan)
v5: - updated to reflect changes in PLPKS API
v4:
- scope reduced to cover just SED Opal keys
- base SED Opal keystore is now in SED block driver
- removed use of enum to indicate type
- refactored common code into common function that read and write use
- removed cast to void
- added use of SED Opal keystore functions to SED block driver
v3:
- No code changes, but per reviewer requests, adding additional mailing lists(keyring, EFI) for wider review.
v2:
- Include feedback from Gregory Joyce, Eric Richter and Murilo Opsfelder Araujo.
- Include suggestions from Michael Ellerman.
- Moved a dependency from generic SED code to this patchset. This patchset now builds of its own.
Greg Joyce (3):
block:sed-opal: SED Opal keystore
block: sed-opal: keystore access for SED Opal keys powerpc/pseries: PLPKS SED Opal keystore support
arch/powerpc/platforms/pseries/Kconfig | 6 + arch/powerpc/platforms/pseries/Makefile | 1 + .../powerpc/platforms/pseries/plpks_sed_ops.c | 131 ++++++++++++++++++ block/Kconfig | 1 + block/sed-opal.c | 18 ++- include/linux/sed-opal-key.h | 26 ++++ 6 files changed, 181 insertions(+), 2 deletions(-) create mode 100644 arch/powerpc/platforms/pseries/plpks_sed_ops.c create mode 100644 include/linux/sed-opal-key.h
Signature · 1 line
[email protected]
PATCH v8 1/3 block:sed-opal: SED Opal keystore
From: Greg Joyce <[email protected]>
Add read and write functions that allow SED Opal keys to stored in a permanent keystore.
--- include/linux/sed-opal-key.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 include/linux/sed-opal-key.h
include/linux/sed-opal-key.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* SED key operations. +* +* Copyright (C) 2023 IBM Corporation +* +* These are the accessor functions (read/write) for SED Opal +* keys. Specific keystores can provide overrides. +* +*/ + +#include <linux/kernel.h> + +#ifdef CONFIG_PSERIES_PLPKS_SED +int sed_read_key (char *keyname,char *key,u_int *keylen); +int sed_write_key (char *keyname,char *key,u_int keylen); +#else +static inline +int sed_read_key (char *keyname,char *key,u_int *keylen) { +return -EOPNOTSUPP ; +} +static inline +int sed_write_key (char *keyname,char *key,u_int keylen) { +return -EOPNOTSUPP ; +} +#endif
Signature · 1 line
[email protected]
PATCH v8 2/3 block: sed-opal: keystore access for SED Opal keys
In reply to [email protected]From: Greg Joyce <[email protected]>
Allow for permanent SED authentication keys by reading/writing to the SED Opal non-volatile keystore.
--- block/sed-opal.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
block/sed-opal.c +16 -2
@@ -18,6 +18,7 @@#include <linux/uaccess.h> #include <uapi/linux/sed-opal.h> #include <linux/sed-opal.h> +#include <linux/sed-opal-key.h> #include <linux/string.h> #include <linux/kdev_t.h> #include <linux/key.h>
@@ -3019,7 +3020,13 @@ static int opal_set_new_pw(struct opal_dev *dev, struct opal_new_pw *opal_pw)if (ret)return ret; -/* update keyring with new password */ +/* update keyring and key store with new password */ + ret =sed_write_key (OPAL_AUTH_KEY , + opal_pw->new_user_pw.opal_key.key, + opal_pw->new_user_pw.opal_key.key_len); +if (ret != -EOPNOTSUPP ) +pr_warn ("error updating SED key: %d\n" , ret); + ret =update_sed_opal_key (OPAL_AUTH_KEY , opal_pw->new_user_pw.opal_key.key, opal_pw->new_user_pw.opal_key.key_len);
@@ -3292,6 +3299,8 @@ EXPORT_SYMBOL_GPL(sed_ioctl);static int __init sed_opal_init (void ) {struct key *kr; +char init_sed_key[OPAL_KEY_MAX ]; +int keylen =OPAL_KEY_MAX -1 ; kr = keyring_alloc(".sed_opal", GLOBAL_ROOT_UID, GLOBAL_ROOT_GID, current_cred(),
@@ -3304,6 +3313,11 @@ static int __init sed_opal_init(void) sed_opal_keyring = kr; -return 0 ; +if (sed_read_key (OPAL_AUTH_KEY , init_sed_key, &keylen) <0 ) { +memset (init_sed_key,'\0' ,sizeof (init_sed_key)); + keylen =OPAL_KEY_MAX -1 ; + } + +return update_sed_opal_key (OPAL_AUTH_KEY , init_sed_key, keylen); }late_initcall (sed_opal_init);
Signature · 1 line
[email protected]
PATCH v8 3/3 powerpc/pseries: PLPKS SED Opal keystore support
In reply to [email protected]From: Greg Joyce <[email protected]>
Define operations for SED Opal to read/write keys from POWER LPAR Platform KeyStore(PLPKS). This allows non-volatile storage of SED Opal keys.
--- arch/powerpc/platforms/pseries/Kconfig | 6 + arch/powerpc/platforms/pseries/Makefile | 1 + .../powerpc/platforms/pseries/plpks_sed_ops.c | 131 ++++++++++++++++++ block/Kconfig | 1 + 4 files changed, 139 insertions(+) create mode 100644 arch/powerpc/platforms/pseries/plpks_sed_ops.c
arch/powerpc/platforms/pseries/Kconfig +6 -0
@@ -164,6 +164,12 @@ config PSERIES_PLPKS # This option is selected by in-kernel consumers that require # access to the PKS. +config PSERIES_PLPKS_SED + depends on PPC_PSERIES + bool + # This option is selected by in-kernel consumers that require + # access to the SED PKS keystore. + config PAPR_SCM depends on PPC_PSERIES && MEMORY_HOTPLUG && LIBNVDIMM tristate "Support for the PAPR Storage Class Memory interface"
arch/powerpc/platforms/pseries/Makefile +1 -0
@@ -29,6 +29,7 @@ obj-$(CONFIG_PPC_SVM) += svm.o obj-$(CONFIG_FA_DUMP) += rtas-fadump.o obj-$(CONFIG_PSERIES_PLPKS) += plpks.o obj-$(CONFIG_PPC_SECURE_BOOT) += plpks-secvar.o +obj-$(CONFIG_PSERIES_PLPKS_SED) += plpks_sed_ops.o obj-$(CONFIG_SUSPEND) += suspend.o obj-$(CONFIG_PPC_VAS) += vas.o vas-sysfs.o
arch/powerpc/platforms/pseries/plpks_sed_ops.c new file +131 -0
131 lines not on this page · raw message
block/Kconfig +1 -0
@@ -186,6 +186,7 @@ config BLK_SED_OPAL bool "Logic for interfacing with Opal enabled SEDs" depends on KEYS select PSERIES_PLPKS if PPC_PSERIES + select PSERIES_PLPKS_SED if PPC_PSERIES help Builds Logic for interfacing with Opal enabled controllers. Enabling this option enables users to setup/unlock/lock
Signature · 1 line
[email protected]
Re: [PATCH v8 3/3] powerpc/pseries: PLPKS SED Opal keystore support
Quoted 10 lines · On Wed, Oct 04, 2023 at 03:19:57PM -0500, [email protected] wrote:
arch/powerpc/platforms/pseries/plpks_sed_ops.c new file +10
-0+int sed_read_key (char *keyname,char *key,u_int *keylen) +{ +struct plpks_var var; +struct plpks_sed_object_data data; +int ret; +u_int len; + +plpks_init_var (&var, keyname); + +if (!plpks_sed_available)
arch/powerpc/platforms/pseries/plpks_sed_ops.c line 89
Quoted 10 lines
arch/powerpc/platforms/pseries/plpks_sed_ops.c new file +10
-0+return -EOPNOTSUPP ; + + var.data = (u8 *)&data; + var.datalen =sizeof (data); + + ret =plpks_read_os_var (&var); +if (ret !=0 ) +return ret; + + len =min_t (u16,be32_to_cpu (data.key_len), var.datalen);
^^^^^^^^^^^
This isn't the correct limit. This is the number of bytes that we copied into data. Probably it's sizeof(data) and, hopefully, it's at least the offsetof(struct plpks_sed_object_data, key).
To me the temptation is the initialize data to zero and s/var.datalen/sizeof(data.key)/.
arch/powerpc/platforms/pseries/plpks_sed_ops.c line 90
Quoted 1 line
arch/powerpc/platforms/pseries/plpks_sed_ops.c new file +1
-0+memcpy (key, data.key, len);
^^^^^^^^
arch/powerpc/platforms/pseries/plpks_sed_ops.c line 95
Quoted 5 lines
arch/powerpc/platforms/pseries/plpks_sed_ops.c new file +5
-0+ key[len] ='\0' ; + *keylen = len; + +return 0 ; +}
regards,
dan carpenter
Hi Jens,
I've addressed all the comments/issues on v7 of the patchset and haven't received any feedback on v8. Is there anything else that you'd like to see before this can be included?
Thanks,
Greg
Quoted 74 lines · On Wed, 2023-10-04 at 15:19 -0500, [email protected] wrote:
From: Greg Joyce <[email protected]>
This patchset has gone through numerous rounds of review and all comments/suggetions have been addressed. The reviews have covered all relevant areas including reviews by block and keyring developers as well as the SED Opal maintainer.
TCG SED Opal is a specification from The Trusted Computing Group that allows self encrypting storage devices (SED) to be locked at power on and require an authentication key to unlock the drive.
PowerPC/pseries versions of key functions provide read/write access to SED Opal keys in the PLPKS keystore.
The SED block driver has been modified to read the SED Opal keystore to populate a key in the SED Opal keyring. Changes to the SED Opal key will be written to the SED Opal keystore.
Changelog
v8: - rebased to 6.6-rc4
- fixed issues using clang (thanks Nathan Chancellor and Nick Desaulniers)
- fixed crash if PLPKS is not present for pseries (thanks
Michael
Ellerman)v7: - rebased to for-6.5/block
v6: - squashed two commits (suggested by Andrew Donnellan)
v5: - updated to reflect changes in PLPKS API
v4:
- scope reduced to cover just SED Opal keys
- base SED Opal keystore is now in SED block driver
- removed use of enum to indicate type
- refactored common code into common function that read and write use
- removed cast to void
- added use of SED Opal keystore functions to SED block
driverv3:
- No code changes, but per reviewer requests, adding
additional
mailinglists(keyring, EFI)for wider review.v2:
- Include feedback from Gregory Joyce, Eric Richter and Murilo Opsfelder Araujo.
- Include suggestions from Michael Ellerman.
- Moved a dependency from generic SED code to this patchset. This patchset now builds of its own.Greg Joyce (3):
block:sed-opal: SED Opal keystore
block: sed-opal: keystore access for SED Opal keys powerpc/pseries: PLPKS SED Opal keystore supportarch/powerpc/platforms/pseries/Kconfig | 6 + arch/powerpc/platforms/pseries/Makefile | 1 + .../powerpc/platforms/pseries/plpks_sed_ops.c | 131 ++++++++++++++++++ block/Kconfig | 1 + block/sed-opal.c | 18 ++- include/linux/sed-opal-key.h | 26 ++++ 6 files changed, 181 insertions(+), 2 deletions(-) create mode 100644 arch/powerpc/platforms/pseries/plpks_sed_ops.c create mode 100644 include/linux/sed-opal-key.h
Jens Axboe
maintainerQuoted 6 lines · Greg Joyce
Hi Jens,
I've addressed all the comments/issues on v7 of the patchset and haven't received any feedback on v8. Is there anything else that you'd like to see before this can be included?
Let's give it another shot!
Signature · 1 line
Jens Axboe
Quoted 10 lines · On Wed, 04 Oct 2023 15:19:54 -0500, [email protected] wrote:
This patchset has gone through numerous rounds of review and all comments/suggetions have been addressed. The reviews have covered all relevant areas including reviews by block and keyring developers as well as the SED Opal maintainer.
TCG SED Opal is a specification from The Trusted Computing Group that allows self encrypting storage devices (SED) to be locked at power on and require an authentication key to unlock the drive.
[...]
Applied, thanks!
[1/3] block:sed-opal: SED Opal keystore
commit: 96ff37ceb203426b1bcebbae42399686110b0130
[2/3] block: sed-opal: keystore access for SED Opal keys
commit: 5dd339722f5f612f349b068e8da6d6710fd0e460
[3/3] powerpc/pseries: PLPKS SED Opal keystore support
commit: ec8cf230ceccfcc2bd29990c2902be168a92dee4Best regards,
Signature · 1 line
Jens Axboe