Skip to content

Commit b21d948

Browse files
gjoyce-ibmaxboe
authored andcommitted
block: sed-opal: add ioctl IOC_OPAL_SET_SID_PW
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. Signed-off-by: Greg Joyce <[email protected]> Reviewed-by: Daniel Wagner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 69f407e commit b21d948

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

block/sed-opal.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3037,6 +3037,29 @@ static int opal_set_new_pw(struct opal_dev *dev, struct opal_new_pw *opal_pw)
30373037
return ret;
30383038
}
30393039

3040+
static int opal_set_new_sid_pw(struct opal_dev *dev, struct opal_new_pw *opal_pw)
3041+
{
3042+
int ret;
3043+
struct opal_key *newkey = &opal_pw->new_user_pw.opal_key;
3044+
struct opal_key *oldkey = &opal_pw->session.opal_key;
3045+
3046+
const struct opal_step pw_steps[] = {
3047+
{ start_SIDASP_opal_session, oldkey },
3048+
{ set_sid_cpin_pin, newkey },
3049+
{ end_opal_session, }
3050+
};
3051+
3052+
if (!dev)
3053+
return -ENODEV;
3054+
3055+
mutex_lock(&dev->dev_lock);
3056+
setup_opal_dev(dev);
3057+
ret = execute_steps(dev, pw_steps, ARRAY_SIZE(pw_steps));
3058+
mutex_unlock(&dev->dev_lock);
3059+
3060+
return ret;
3061+
}
3062+
30403063
static int opal_activate_user(struct opal_dev *dev,
30413064
struct opal_session_info *opal_session)
30423065
{
@@ -3286,6 +3309,9 @@ int sed_ioctl(struct opal_dev *dev, unsigned int cmd, void __user *arg)
32863309
case IOC_OPAL_DISCOVERY:
32873310
ret = opal_get_discv(dev, p);
32883311
break;
3312+
case IOC_OPAL_SET_SID_PW:
3313+
ret = opal_set_new_sid_pw(dev, p);
3314+
break;
32893315

32903316
default:
32913317
break;

include/linux/sed-opal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ static inline bool is_sed_ioctl(unsigned int cmd)
5252
case IOC_OPAL_GET_GEOMETRY:
5353
case IOC_OPAL_DISCOVERY:
5454
case IOC_OPAL_REVERT_LSP:
55+
case IOC_OPAL_SET_SID_PW:
5556
return true;
5657
}
5758
return false;

include/uapi/linux/sed-opal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,5 +215,6 @@ struct opal_revert_lsp {
215215
#define IOC_OPAL_GET_GEOMETRY _IOR('p', 238, struct opal_geometry)
216216
#define IOC_OPAL_DISCOVERY _IOW('p', 239, struct opal_discovery)
217217
#define IOC_OPAL_REVERT_LSP _IOW('p', 240, struct opal_revert_lsp)
218+
#define IOC_OPAL_SET_SID_PW _IOW('p', 241, struct opal_new_pw)
218219

219220
#endif /* _UAPI_SED_OPAL_H */

0 commit comments

Comments
 (0)