Skip to contentSkip to conversation

add ioctl IOC_OPAL_SET_SID_PW

PATCH Applied [email protected] 2 participants 4 messages Aug 29, 2024 – Oct 8, 2024

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

v2 cover add ioctl IOC_OPAL_SET_SID_PW

From: Greg Joyce <[email protected]>

This version does not reflect any code changes since there have been no comments on the patchset since the original submission on 13 Aug 2024.

As requersted, it does contain an expanded description of the patchset and a pointer to the CLI change. Thanks
to Daniel Wagner and Michal Suchánek for the feedback.

SED Opal allows a password for the SID user as well as the Admin1 user. If a CLI wishes to change the password of both users there is currently no way to accomplish that using the SED Opal block driver ioctls. The Admin1 password can be changes using the IOC_OPAL_SET_PW ioctl but the SID password remains the password that was set when the SED drive was provisioned (ownership).

To allow a CLI to change the SID password, a new ioctl IOC_OPAL_SET_SID_PW has been created. The valid current password is required to change the SID password.

The nvme-cli has been changed to use this ioctl such that the "sed password" can change both the Admin1 and SID passwords. The pull request can be found here:

	https://github.com/linux-nvme/nvme-cli/pull/2467

Greg Joyce (1):
block: sed-opal: add ioctl IOC_OPAL_SET_SID_PW

 block/sed-opal.c              | 26 ++++++++++++++++++++++++++
 include/linux/sed-opal.h      |  1 +
 include/uapi/linux/sed-opal.h |  1 +
 3 files changed, 28 insertions(+)
Signature · 1 line
[email protected]
#1 lore raw

PATCH v2 1/1 block: sed-opal: add ioctl IOC_OPAL_SET_SID_PW

From: Greg Joyce <[email protected]>

After a SED drive is provisioned, there is no way to change the SID password via the ioctl() interface. A new ioctl IOC_OPAL_SET_SID_PW will allow the password to be changed. The valid current password is required.

---
 block/sed-opal.c              | 26 ++++++++++++++++++++++++++
 include/linux/sed-opal.h      |  1 +
 include/uapi/linux/sed-opal.h |  1 +
 3 files changed, 28 insertions(+)
block/sed-opal.c +26 -0
index 598fd3e7fcc8..5a28f23f7f22 100644
@@ -3037,6 +3037,29 @@ static int opal_set_new_pw(struct opal_dev *dev, struct opal_new_pw *opal_pw)
 	return ret;
 }
 
+static int opal_set_new_sid_pw(struct opal_dev *dev, struct opal_new_pw *opal_pw)
+{
+	int ret;
+	struct opal_key *newkey = &opal_pw->new_user_pw.opal_key;
+	struct opal_key *oldkey = &opal_pw->session.opal_key;
+
+	const struct opal_step pw_steps[] = {
+		{ start_SIDASP_opal_session, oldkey },
+		{ set_sid_cpin_pin, newkey },
+		{ end_opal_session, }
+	};
+
+	if (!dev)
+		return -ENODEV;
+
+	mutex_lock(&dev->dev_lock);
+	setup_opal_dev(dev);
+	ret = execute_steps(dev, pw_steps, ARRAY_SIZE(pw_steps));
+	mutex_unlock(&dev->dev_lock);
+
+	return ret;
+}
+
 static int opal_activate_user(struct opal_dev *dev,
 			      struct opal_session_info *opal_session)
 {
@@ -3286,6 +3309,9 @@ int sed_ioctl(struct opal_dev *dev, unsigned int cmd, void __user *arg)
 	case IOC_OPAL_DISCOVERY:
 		ret = opal_get_discv(dev, p);
 		break;
+	case IOC_OPAL_SET_SID_PW:
+		ret = opal_set_new_sid_pw(dev, p);
+		break;
 
 	default:
 		break;
include/linux/sed-opal.h +1 -0
index 2ac50822554e..80f33a93f944 100644
@@ -52,6 +52,7 @@ static inline bool is_sed_ioctl(unsigned int cmd)
 	case IOC_OPAL_GET_GEOMETRY:
 	case IOC_OPAL_DISCOVERY:
 	case IOC_OPAL_REVERT_LSP:
+	case IOC_OPAL_SET_SID_PW:
 		return true;
 	}
 	return false;
include/uapi/linux/sed-opal.h +1 -0
index d3994b7716bc..9025dd5a4f0f 100644
@@ -215,5 +215,6 @@ struct opal_revert_lsp {
 #define IOC_OPAL_GET_GEOMETRY       _IOR('p', 238, struct opal_geometry)
 #define IOC_OPAL_DISCOVERY          _IOW('p', 239, struct opal_discovery)
 #define IOC_OPAL_REVERT_LSP         _IOW('p', 240, struct opal_revert_lsp)
+#define IOC_OPAL_SET_SID_PW         _IOW('p', 241, struct opal_new_pw)
 
 #endif /* _UAPI_SED_OPAL_H */
Signature · 1 line
[email protected]
author
#2 lore raw
In reply to [email protected]

It's been about a month with no comments. Does anyone have any feedback on this patchset?

Thanks,
Greg

Quoted 34 lines · On Thu, 2024-08-29 at 12:56 -0500, [email protected] wrote:

From: Greg Joyce <[email protected]>

This version does not reflect any code changes since there have been no comments on the patchset since the original submission on 13 Aug 2024.

As requersted, it does contain an expanded description of the patchset and a pointer to the CLI change. Thanks
to Daniel Wagner and Michal Suchánek for the feedback.

SED Opal allows a password for the SID user as well as the Admin1 user. If a CLI wishes to change the password of both users there is currently no way to accomplish that using the SED Opal block driver ioctls. The Admin1 password can be changes using the IOC_OPAL_SET_PW ioctl but the SID password remains the password that was set when the SED drive was provisioned (ownership).

To allow a CLI to change the SID password, a new ioctl IOC_OPAL_SET_SID_PW has been created. The valid current password is required to change the SID password.

The nvme-cli has been changed to use this ioctl such that the "sed password" can change both the Admin1 and SID passwords. The pull request can be found here:

	https://github.com/linux-nvme/nvme-cli/pull/2467

Greg Joyce (1):
  block: sed-opal: add ioctl IOC_OPAL_SET_SID_PW

 block/sed-opal.c              | 26 ++++++++++++++++++++++++++ include/linux/sed-opal.h      |  1 + include/uapi/linux/sed-opal.h |  1 +

 3 files changed, 28 insertions(+)
maintainer Applied
#3 lore raw
In reply to [email protected]
Quoted 9 lines · On Thu, 29 Aug 2024 12:56:10 -0500, [email protected] wrote:

This version does not reflect any code changes since there have been no comments on the patchset since the original submission on 13 Aug 2024.

As requersted, it does contain an expanded description of the patchset and a pointer to the CLI change. Thanks
to Daniel Wagner and Michal Suchánek for the feedback.

[...]

Applied, thanks!

[1/1] block: sed-opal: add ioctl IOC_OPAL_SET_SID_PW

      commit: 010194b33241ca05a0ccc952dcb94f89f68b9846

Best regards,

Signature · 1 line
Jens Axboe