Skip to contentSkip to conversation

sed-opal: keyrings, discovery, revert and key store

PATCH In review [email protected] 4 participants 12 messages Jul 18, 2022 – Jul 28, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover sed-opal: keyrings, discovery, revert and key store

From: Greg Joyce <[email protected]>

The current TCG SED Opal implementation in the block driver requires that authentication keys be provided in an ioctl so that they can be presented to the underlying SED Opal capable drive. Currently, the key is typically entered by a user with an application like sedutil or sedcli. While this process works, it does not lend itself to automation like unlock by a udev rule.

Extend the SED block driver so it can alternatively obtain a key from a sed-opal kernel keyring. The SED ioctls will indicate the source of the key, either directly in the ioctl data or from the keyring.

Two new SED ioctls have also been added. These are:
1) IOC_OPAL_REVERT_LSP to revert LSP state
2) IOC_OPAL_DISCOVERY to discover drive capabilities/state

Also, for platforms that have a permanent key store, the platform may provide unique platform dependent functions to read/write variables. The SED block driver has been modified to attempt to read a key from the platform key store. If successful, the key value is saved in the kernel sed-opal keyring. If the platform does not support a permanent key store, the read will fail and a key will not be added to the keyring. This patchset does not include any providers of the variable read/write functions.

base-commit: ff6992735ade75aae3e35d16b17da1008d753d28

Greg Joyce (4):
block: sed-opal: Implement IOC_OPAL_DISCOVERY
block: sed-opal: Implement IOC_OPAL_REVERT_LSP
block: sed-opal: keyring support for SED Opal keys
arch_vars: create arch specific permanent store

 block/Kconfig                 |   1 +
 block/opal_proto.h            |   4 +
 block/sed-opal.c              | 274 +++++++++++++++++++++++++++++++++-
 include/linux/arch_vars.h     |  23 +++
 include/linux/sed-opal.h      |   5 +
 include/uapi/linux/sed-opal.h |  24 ++-
 lib/Makefile                  |   2 +-
 lib/arch_vars.c               |  25 ++++
 8 files changed, 351 insertions(+), 7 deletions(-)
 create mode 100644 include/linux/arch_vars.h
 create mode 100644 lib/arch_vars.c
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/4 block: sed-opal: Implement IOC_OPAL_DISCOVERY

From: Greg Joyce <[email protected]>

Add IOC_OPAL_DISCOVERY ioctl to return raw discovery data to a SED Opal application. This allows the application to display drive capabilities and state.

---
 block/sed-opal.c              | 38 ++++++++++++++++++++++++++++++++---
 include/linux/sed-opal.h      |  1 +
 include/uapi/linux/sed-opal.h |  7 +++++++
 3 files changed, 43 insertions(+), 3 deletions(-)
block/sed-opal.c +35 -3
index 9700197000f2..4b9a7ffbf00f 100644
@@ -426,8 +426,11 @@ static int execute_steps(struct opal_dev *dev,
 	return error;
 }
 
-static int opal_discovery0_end(struct opal_dev *dev)
+static int opal_discovery0_end(struct opal_dev *dev, void *data)
 {
+	struct opal_discovery *discv_out = data; /* may be NULL */
+	u8 __user *buf_out;
+	u64 len_out;
 	bool found_com_id = false, supported = true, single_user = false;
 	const struct d0_header *hdr = (struct d0_header *)dev->resp;
 	const u8 *epos = dev->resp, *cpos = dev->resp;
@@ -443,6 +446,15 @@ static int opal_discovery0_end(struct opal_dev *dev)
 		return -EFAULT;
 	}
 
+	if (discv_out) {
+		buf_out = (u8 __user *)(uintptr_t)discv_out->data;
+		len_out = min(discv_out->size, (u64)hlen);
+		if (buf_out && copy_to_user(buf_out, dev->resp, len_out)) {
+			return -EFAULT;
+		}
+		discv_out->size = hlen; /* actual size of data */
+	}
+
 	epos += hlen; /* end of buffer */
 	cpos += sizeof(*hdr); /* current position on buffer */
 
@@ -517,13 +529,13 @@ static int opal_discovery0(struct opal_dev *dev, void *data)
 	if (ret)
 		return ret;
 
-	return opal_discovery0_end(dev);
+	return opal_discovery0_end(dev, data);
 }
 
 static int opal_discovery0_step(struct opal_dev *dev)
 {
 	const struct opal_step discovery0_step = {
-		opal_discovery0,
+		opal_discovery0, NULL
 	};
 
 	return execute_step(dev, &discovery0_step, 0);
@@ -2179,6 +2191,22 @@ static int opal_secure_erase_locking_range(struct opal_dev *dev,
 	return ret;
 }
 
+static int opal_get_discv(struct opal_dev *dev, struct opal_discovery *discv)
+{
+	const struct opal_step discovery0_step = {
+		opal_discovery0, discv
+	};
+	int ret = 0;
+
+	mutex_lock(&dev->dev_lock);
+	setup_opal_dev(dev);
+	ret = execute_step(dev, &discovery0_step, 0);
+	mutex_unlock(&dev->dev_lock);
+	if (ret)
+		return ret;
+	return discv->size; /* modified to actual length of data */
+}
+
 static int opal_erase_locking_range(struct opal_dev *dev,
 				    struct opal_session_info *opal_session)
 {
@@ -2685,6 +2713,10 @@ int sed_ioctl(struct opal_dev *dev, unsigned int cmd, void __user *arg)
 	case IOC_OPAL_GENERIC_TABLE_RW:
 		ret = opal_generic_read_write_table(dev, p);
 		break;
+	case IOC_OPAL_DISCOVERY:
+		ret = opal_get_discv(dev, p);
+		break;
+
 	default:
 		break;
 	}
include/linux/sed-opal.h +1 -0
index 1ac0d712a9c3..9197b7a628f2 100644
@@ -43,6 +43,7 @@ static inline bool is_sed_ioctl(unsigned int cmd)
 	case IOC_OPAL_MBR_DONE:
 	case IOC_OPAL_WRITE_SHADOW_MBR:
 	case IOC_OPAL_GENERIC_TABLE_RW:
+	case IOC_OPAL_DISCOVERY:
 		return true;
 	}
 	return false;
include/uapi/linux/sed-opal.h +7 -0
index 6f5af1a84213..114636c19d31 100644
@@ -132,6 +132,12 @@ struct opal_read_write_table {
 	__u64 priv;
 };
 
+struct opal_discovery {
+	__u64 data;
+	__u64 size;
+};
+
+
 #define IOC_OPAL_SAVE		    _IOW('p', 220, struct opal_lock_unlock)
 #define IOC_OPAL_LOCK_UNLOCK	    _IOW('p', 221, struct opal_lock_unlock)
 #define IOC_OPAL_TAKE_OWNERSHIP	    _IOW('p', 222, struct opal_key)
@@ -148,5 +154,6 @@ struct opal_read_write_table {
 #define IOC_OPAL_MBR_DONE           _IOW('p', 233, struct opal_mbr_done)
 #define IOC_OPAL_WRITE_SHADOW_MBR   _IOW('p', 234, struct opal_shadow_mbr)
 #define IOC_OPAL_GENERIC_TABLE_RW   _IOW('p', 235, struct opal_read_write_table)
+#define IOC_OPAL_DISCOVERY          _IOW('p', 236, struct opal_discovery)
 
 #endif /* _UAPI_SED_OPAL_H */
Signature · 1 line
2.27.0
Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] block: sed-opal: Implement IOC_OPAL_DISCOVERY

block/sed-opal.c static int opal_discovery0_end(struct opal_dev *dev) · line 454

Quoted 6 lines · On Mon, Jul 18, 2022 at 04:01:53PM -0500, [email protected] wrote:
block/sed-opal.c +6 -0
+	if (discv_out) {
+		buf_out = (u8 __user *)(uintptr_t)discv_out->data;
+		len_out = min(discv_out->size, (u64)hlen);
+		if (buf_out && copy_to_user(buf_out, dev->resp, len_out)) {
+			return -EFAULT;
+		}

No need for the braces here.

Otherwise looks good:

#3 lore raw

PATCH 2/4 block: sed-opal: Implement IOC_OPAL_REVERT_LSP

In reply to [email protected]

From: Greg Joyce <[email protected]>

This is used in conjunction with IOC_OPAL_REVERT_TPR to return a drive to Original Factory State without erasing the data. If IOC_OPAL_REVERT_LSP is called with opal_revert_lsp.options bit OPAL_PRESERVE set prior to calling IOC_OPAL_REVERT_TPR, the drive global locking range will not be erased.

---
 block/opal_proto.h            |  4 ++++
 block/sed-opal.c              | 42 ++++++++++++++++++++++++++++++++++-
 include/linux/sed-opal.h      |  1 +
 include/uapi/linux/sed-opal.h |  9 ++++++++
 4 files changed, 55 insertions(+), 1 deletion(-)
block/opal_proto.h +4 -0
index b486b3ec7dc4..6127c08267f8 100644
@@ -210,6 +210,10 @@ enum opal_parameter {
 	OPAL_SUM_SET_LIST = 0x060000,
 };
 
+enum opal_revertlsp {
+	OPAL_KEEP_GLOBAL_RANGE_KEY = 0x060000,
+};
+
 /* Packets derived from:
  * TCG_Storage_Architecture_Core_Spec_v2.01_r1.00
  * Secion: 3.2.3 ComPackets, Packets & Subpackets
block/sed-opal.c +41 -1

66 lines not on this page · raw message

include/linux/sed-opal.h +1 -0
index 9197b7a628f2..3a6082ff97e7 100644
@@ -43,6 +43,7 @@ static inline bool is_sed_ioctl(unsigned int cmd)
 	case IOC_OPAL_MBR_DONE:
 	case IOC_OPAL_WRITE_SHADOW_MBR:
 	case IOC_OPAL_GENERIC_TABLE_RW:
+	case IOC_OPAL_REVERT_LSP:
 	case IOC_OPAL_DISCOVERY:
 		return true;
 	}
include/uapi/linux/sed-opal.h +9 -0
index 114636c19d31..afbce867b906 100644
@@ -51,6 +51,10 @@ struct opal_key {
 	__u8 key[OPAL_KEY_MAX];
 };
 
+enum opal_revert_lsp_opts {
+	OPAL_PRESERVE = 0x01,
+};
+
 struct opal_lr_act {
 	struct opal_key key;
 	__u32 sum;
@@ -137,6 +141,10 @@ struct opal_discovery {
 	__u64 size;
 };
 
+struct opal_revert_lsp {
+	struct opal_key key;
+	__u32 options;
+};
 
 #define IOC_OPAL_SAVE		    _IOW('p', 220, struct opal_lock_unlock)
 #define IOC_OPAL_LOCK_UNLOCK	    _IOW('p', 221, struct opal_lock_unlock)
@@ -155,5 +163,6 @@ struct opal_discovery {
 #define IOC_OPAL_WRITE_SHADOW_MBR   _IOW('p', 234, struct opal_shadow_mbr)
 #define IOC_OPAL_GENERIC_TABLE_RW   _IOW('p', 235, struct opal_read_write_table)
 #define IOC_OPAL_DISCOVERY          _IOW('p', 236, struct opal_discovery)
+#define IOC_OPAL_REVERT_LSP         _IOW('p', 237, struct opal_revert_lsp)
 
 #endif /* _UAPI_SED_OPAL_H */
Signature · 1 line
2.27.0
#4 lore raw

Re: [PATCH 2/4] block: sed-opal: Implement IOC_OPAL_REVERT_LSP

Quoted 36 lines · On Mon, Jul 18, 2022 at 04:01:54PM -0500, [email protected] wrote:

From: Greg Joyce <[email protected]>

This is used in conjunction with IOC_OPAL_REVERT_TPR to return a drive to Original Factory State without erasing the data. If IOC_OPAL_REVERT_LSP is called with opal_revert_lsp.options bit OPAL_PRESERVE set prior to calling IOC_OPAL_REVERT_TPR, the drive global locking range will not be erased.

---
 block/opal_proto.h            |  4 ++++
 block/sed-opal.c              | 42 ++++++++++++++++++++++++++++++++++-
 include/linux/sed-opal.h      |  1 +
 include/uapi/linux/sed-opal.h |  9 ++++++++
 4 files changed, 55 insertions(+), 1 deletion(-)
block/opal_proto.h +4 -0
index b486b3ec7dc4..6127c08267f8 100644
@@ -210,6 +210,10 @@ enum opal_parameter {
 	OPAL_SUM_SET_LIST = 0x060000,
 };
 
+enum opal_revertlsp {
+	OPAL_KEEP_GLOBAL_RANGE_KEY = 0x060000,
+};
+
 /* Packets derived from:
  * TCG_Storage_Architecture_Core_Spec_v2.01_r1.00
  * Secion: 3.2.3 ComPackets, Packets & Subpackets
block/sed-opal.c +0 -0
index 4b9a7ffbf00f..feba36e54ae0 100644

block/sed-opal.c static int opal_discovery0_end(struct opal_dev *dev, void *data) · line 451

Quoted 5 lines
block/sed-opal.c +1 -1
@@ -448,7 +448,7 @@ static int opal_discovery0_end(struct opal_dev *dev, void *data)
 
 	if (discv_out) {
 		buf_out = (u8 __user *)(uintptr_t)discv_out->data;
-		len_out = min(discv_out->size, (u64)hlen);
+		len_out = min_t(u64, discv_out->size, hlen);

This seems like it should go into the previous patch (or just dropped).

block/sed-opal.c struct opal_discovery { · line 146

Quoted 11 lines
block/sed-opal.c +4 -0
+
 struct opal_lr_act {
 	struct opal_key key;
 	__u32 sum;
@@ -137,6 +141,10 @@ struct opal_discovery {
 	__u64 size;
 };
 
+struct opal_revert_lsp {
+	struct opal_key key;
+	__u32 options;

this wants a __u32 __pad at the end to avoid struct padding problems.

#5 lore raw

PATCH 3/4 block: sed-opal: keyring support for SED Opal keys

In reply to [email protected]

From: Greg Joyce <[email protected]>

Extend the SED block driver so it can alternatively obtain a key from a sed-opal kernel keyring. The SED ioctls will indicate the source of the key, either directly in the ioctl data or from the keyring.

This allows the use of SED commands in scripts such as udev scripts so that drives may be automatically unlocked as they become available.

---
 block/Kconfig                 |   1 +
 block/sed-opal.c              | 198 +++++++++++++++++++++++++++++++++-
 include/linux/sed-opal.h      |   3 +
 include/uapi/linux/sed-opal.h |   8 +-
 4 files changed, 206 insertions(+), 4 deletions(-)
block/Kconfig +1 -0
index 50b17e260fa2..f65169e9356b 100644
@@ -182,6 +182,7 @@ config BLK_DEBUG_FS_ZONED
 
 config BLK_SED_OPAL
 	bool "Logic for interfacing with Opal enabled SEDs"
+	depends on KEYS
 	help
 	Builds Logic for interfacing with Opal enabled controllers.
 	Enabling this option enables users to setup/unlock/lock
block/sed-opal.c +195 -3

322 lines not on this page · raw message

include/linux/sed-opal.h +3 -0
index 3a6082ff97e7..ed21e47bf773 100644
@@ -24,6 +24,9 @@ bool opal_unlock_from_suspend(struct opal_dev *dev);
 struct opal_dev *init_opal_dev(void *data, sec_send_recv *send_recv);
 int sed_ioctl(struct opal_dev *dev, unsigned int cmd, void __user *ioctl_ptr);
 
+#define	OPAL_AUTH_KEY           "opal-boot-pin"
+#define	OPAL_AUTH_KEY_PREV      "opal-boot-pin-prev"
+
 static inline bool is_sed_ioctl(unsigned int cmd)
 {
 	switch (cmd) {
include/uapi/linux/sed-opal.h +7 -1
index afbce867b906..aacaa4c8823f 100644
@@ -44,10 +44,16 @@ enum opal_lock_state {
 	OPAL_LK = 0x04, /* 0100 */
 };
 
+enum opal_key_type {
+	OPAL_INCLUDED = 0,	/* key[] is the key */
+	OPAL_KEYRING,		/* key is in keyring */
+};
+
 struct opal_key {
 	__u8 lr;
 	__u8 key_len;
-	__u8 __align[6];
+	__u8 key_type;
+	__u8 __align[5];
 	__u8 key[OPAL_KEY_MAX];
 };
 
Signature · 1 line
2.27.0
#6 lore raw

Re: [PATCH 3/4] block: sed-opal: keyring support for SED Opal keys

Quoted 73 lines · On 7/18/22 23:01, [email protected] wrote:

From: Greg Joyce <[email protected]>

Extend the SED block driver so it can alternatively obtain a key from a sed-opal kernel keyring. The SED ioctls will indicate the source of the key, either directly in the ioctl data or from the keyring.

This allows the use of SED commands in scripts such as udev scripts so that drives may be automatically unlocked as they become available.

---
  block/Kconfig                 |   1 +
  block/sed-opal.c              | 198 +++++++++++++++++++++++++++++++++-
  include/linux/sed-opal.h      |   3 +
  include/uapi/linux/sed-opal.h |   8 +-
  4 files changed, 206 insertions(+), 4 deletions(-)
block/Kconfig +1 -0
index 50b17e260fa2..f65169e9356b 100644
@@ -182,6 +182,7 @@ config BLK_DEBUG_FS_ZONED
 
  config BLK_SED_OPAL
  	bool "Logic for interfacing with Opal enabled SEDs"
+	depends on KEYS
  	help
  	Builds Logic for interfacing with Opal enabled controllers.
  	Enabling this option enables users to setup/unlock/lock
block/sed-opal.c +19 -0
index feba36e54ae0..4cfc3458cba5 100644
@@ -20,6 +20,10 @@
  #include <linux/sed-opal.h>
  #include <linux/string.h>
  #include <linux/kdev_t.h>
+#include <linux/key.h>
+#include <linux/key-type.h>
+#include <linux/arch_vars.h>
+#include <keys/user-type.h>
 
  #include "opal_proto.h"
 
@@ -29,6 +33,8 @@
  /* Number of bytes needed by cmd_finalize. */
  #define CMD_FINALIZE_BYTES_NEEDED 7
 
+static struct key *sed_opal_keyring;
+
  struct opal_step {
  	int (*fn)(struct opal_dev *dev, void *data);
  	void *data;
@@ -266,6 +272,107 @@ static void print_buffer(const u8 *ptr, u32 length)
  #endif
  }
 
+/*
+ * Allocate/update a SED Opal key and add it to the SED Opal keyring.
+ */
+static int update_sed_opal_key(const char *desc, u_char *key_data, int keylen)
+{
+	int ret;
+	struct key *key;
+
+	if (!sed_opal_keyring)
+		return -ENOKEY;
+
+	key = key_alloc(&key_type_user, desc, GLOBAL_ROOT_UID, GLOBAL_ROOT_GID,
+			current_cred(),

block/sed-opal.c static void print_buffer(const u8 *ptr, u32 length) · line 297

Quoted 10 lines
block/sed-opal.c +10 -0
+			KEY_USR_VIEW | KEY_USR_SEARCH | KEY_USR_WRITE,
+			0,
+			NULL);
+	if (IS_ERR(key))
+		return PTR_ERR(key);
+
+	ret = key_instantiate_and_link(key, key_data, keylen,
+				       sed_opal_keyring, NULL);
+	key_put(key);
+

Maybe you should consider 'key_create_or_update() here, as it combines both operations.
Also the 'key_instantiate_and_link()' operation will always insert the key, so you might end up with key duplicates.

Cheers,

Hannes

#7 lore raw

Re: [PATCH 3/4] block: sed-opal: keyring support for SED Opal keys

In reply to [email protected]

I don't know the keyring code at all, so just some nitpicks here:

block/sed-opal.c static void print_buffer(const u8 *ptr, u32 length) · line 319

Quoted 7 lines
block/sed-opal.c +7 -0
+	kref = keyring_search(make_key_ref(sed_opal_keyring, true),
+			      &key_type_user,
+			      key_name,
+			      true);
+
+	if (IS_ERR(kref)) {
+		ret = PTR_ERR(kref);

Just return directly here instead of indenting the main path. Also the parameter list and empty line here look odd. Why not:

	kref = keyring_search(make_key_ref(sed_opal_keyring, true),
			      &key_type_user, key_name, true);
	if (IS_ERR(kref))
		return PTR_ERR(kref);

?

block/sed-opal.c static int opal_set_new_pw(struct opal_dev *dev, struct opal_new_pw *opal_pw) · line 2703

Quoted 4 lines
block/sed-opal.c +1 -0
 	ret = execute_steps(dev, pw_steps, ARRAY_SIZE(pw_steps));
 	mutex_unlock(&dev->dev_lock);
 
+	if (ret == 0) {
	if (ret)
		return ret;

and avoid the indentation below.

block/sed-opal.c int sed_ioctl(struct opal_dev *dev, unsigned int cmd, void __user *arg) · line 2957

Quoted 3 lines
block/sed-opal.c +3 -0
+	ret = update_sed_opal_key(OPAL_AUTH_KEY, init_sed_key, keylen);
+
+	return ret;
	return update_sed_opal_key(OPAL_AUTH_KEY, init_sed_key, keylen);

include/uapi/linux/sed-opal.h enum opal_lock_state { · line 56

Quoted 12 lines
include/uapi/linux/sed-opal.h +7 -1
+enum opal_key_type {
+	OPAL_INCLUDED = 0,	/* key[] is the key */
+	OPAL_KEYRING,		/* key is in keyring */
+};
+
 struct opal_key {
 	__u8 lr;
 	__u8 key_len;
-	__u8 __align[6];
+	__u8 key_type;
+	__u8 __align[5];

Can we assume this was always zero initialized before?

#8 lore raw

PATCH 4/4 arch_vars: create arch specific permanent store

In reply to [email protected]

From: Greg Joyce <[email protected]>

Platforms that have a permanent key store may provide unique platform dependent functions to read/write variables. The default (weak) functions return -EOPNOTSUPP unless overridden by architecture/platform versions.

---
 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
include/linux/arch_vars.h new file +23 -0
new file mode 100644
index 000000000000..9c280ff9432e
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Platform variable opearations.
+ *
+ * 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>
+
+enum arch_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 */
+};
+
+int arch_read_variable(enum arch_variable_type type, char *varname,
+		       void *varbuf, u_int *varlen);
+int arch_write_variable(enum arch_variable_type type, char *varname,
+			void *varbuf, u_int varlen);
lib/Makefile +1 -1
index f99bf61f8bbc..b90c4cb0dbbb 100644
@@ -48,7 +48,7 @@ obj-y += bcd.o sort.o parser.o debug_locks.o random32.o \
 	 bsearch.o find_bit.o llist.o memweight.o kfifo.o \
 	 percpu-refcount.o rhashtable.o \
 	 once.o refcount.o usercopy.o errseq.o bucket_locks.o \
-	 generic-radix-tree.o
+	 generic-radix-tree.o arch_vars.o
 obj-$(CONFIG_STRING_SELFTEST) += test_string.o
 obj-y += string_helpers.o
 obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o
lib/arch_vars.c new file +25 -0
new file mode 100644
index 000000000000..e6f16d7d09c1
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Platform variable operations.
+ *
+ * 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)
+{
+	return -EOPNOTSUPP;
+}
+
+int __weak arch_write_variable(enum arch_variable_type type, char *varname,
+			       void *varbuf, u_int varlen)
+{
+	return -EOPNOTSUPP;
+}
Signature · 1 line
2.27.0
#9 lore raw

Re: [PATCH 4/4] arch_vars: create arch specific permanent store

Quoted 6 lines · On Mon, Jul 18, 2022 at 04:01:56PM -0500, [email protected] wrote:

From: Greg Joyce <[email protected]>

Platforms that have a permanent key store may provide unique platform dependent functions to read/write variables. The default (weak) functions return -EOPNOTSUPP unless overridden by architecture/platform versions.

This is still lacking any useful implementation. It also seems to be used in patch 3 before it actually is used.

As the functionality seems optional I'd suggest to drop this patch for now and not call it from patch 3, and do a separate series later that adds the infrastructure, at leat one useful backend and the caller.

author
#10 lore raw

Re: [PATCH 4/4] arch_vars: create arch specific permanent store

Quoted 9 lines · Christoph Hellwig
Quoted 6 lines · On Mon, Jul 18, 2022 at 04:01:56PM -0500, [email protected] wrote:

From: Greg Joyce <[email protected]>

Platforms that have a permanent key store may provide unique platform dependent functions to read/write variables. The default (weak) functions return -EOPNOTSUPP unless overridden by architecture/platform versions.

Quoted 7 lines

This is still lacking any useful implementation. It also seems to be used in patch 3 before it actually is used.

As the functionality seems optional I'd suggest to drop this patch for
now and not call it from patch 3, and do a separate series later that adds the infrastructure, at leat one useful backend and the caller.

It's kind of a chicken and egg thing. I'd hoped to add the infrastructure and follow it up with another pseries specific patchset that provided platform specific implementations of those functions.

But I can break it up as you suggest. I'll include your other comments as well as the keyring suggestion from Hannes.

maintainer
#11 lore raw
In reply to [email protected]
Quoted 10 lines · On Mon, Jul 18, 2022 at 04:01:52PM -0500, [email protected] wrote:

From: Greg Joyce <[email protected]>

The current TCG SED Opal implementation in the block driver requires that authentication keys be provided in an ioctl so that they can be presented to the underlying SED Opal capable drive. Currently, the key is typically entered by a user with an application like sedutil or sedcli. While this process works, it does not lend itself to automation like unlock by a udev rule.

Please explain also what SED Opal is.

Quoted 30 lines

Extend the SED block driver so it can alternatively obtain a key from a sed-opal kernel keyring. The SED ioctls will indicate the source of the key, either directly in the ioctl data or from the keyring.

Two new SED ioctls have also been added. These are:
1) IOC_OPAL_REVERT_LSP to revert LSP state
2) IOC_OPAL_DISCOVERY to discover drive capabilities/state

Also, for platforms that have a permanent key store, the platform may provide unique platform dependent functions to read/write variables. The SED block driver has been modified to attempt to read a key from the platform key store. If successful, the key value is saved in the kernel sed-opal keyring. If the platform does not support a permanent key store, the read will fail and a key will not be added to the keyring. This patchset does not include any providers of the variable read/write functions.

base-commit: ff6992735ade75aae3e35d16b17da1008d753d28

Greg Joyce (4):
block: sed-opal: Implement IOC_OPAL_DISCOVERY
block: sed-opal: Implement IOC_OPAL_REVERT_LSP
block: sed-opal: keyring support for SED Opal keys
arch_vars: create arch specific permanent store

Quoted 16 lines
 block/Kconfig                 |   1 +
 block/opal_proto.h            |   4 +
 block/sed-opal.c              | 274 +++++++++++++++++++++++++++++++++-
 include/linux/arch_vars.h     |  23 +++
 include/linux/sed-opal.h      |   5 +
 include/uapi/linux/sed-opal.h |  24 ++-
 lib/Makefile                  |   2 +-
 lib/arch_vars.c               |  25 ++++
 8 files changed, 351 insertions(+), 7 deletions(-)
 create mode 100644 include/linux/arch_vars.h
 create mode 100644 lib/arch_vars.c
Signature · 1 line
2.27.0

BR, Jarkko