Commit 5e4c7cf6 authored by Revanth Rajashekar's avatar Revanth Rajashekar Committed by Jens Axboe

block: sed-opal: PSID reverttper capability

PSID is a 32 character password printed on the drive label,
to prove its physical access. This PSID reverttper function
is very useful to regain the control over the drive when it
is locked and the user can no longer access it because of some
failures. However, *all the data on the drive is completely
erased*. This method is advisable only when the user is exhausted
of all other recovery methods.

PSID capabilities are described in:
https://trustedcomputinggroup.org/wp-content/uploads/TCG_Storage-Opal_Feature_Set_PSID_v1.00_r1.00.pdfSigned-off-by: default avatarRevanth Rajashekar <revanth.rajashekar@intel.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent fbbe7c86
......@@ -1307,6 +1307,7 @@ static int start_generic_opal_session(struct opal_dev *dev,
break;
case OPAL_ADMIN1_UID:
case OPAL_SID_UID:
case OPAL_PSID_UID:
add_token_u8(&err, dev, OPAL_STARTNAME);
add_token_u8(&err, dev, 0); /* HostChallenge */
add_token_bytestring(&err, dev, key, key_len);
......@@ -1367,6 +1368,16 @@ static int start_admin1LSP_opal_session(struct opal_dev *dev, void *data)
key->key, key->key_len);
}
static int start_PSID_opal_session(struct opal_dev *dev, void *data)
{
const struct opal_key *okey = data;
return start_generic_opal_session(dev, OPAL_PSID_UID,
OPAL_ADMINSP_UID,
okey->key,
okey->key_len);
}
static int start_auth_opal_session(struct opal_dev *dev, void *data)
{
struct opal_session_info *session = data;
......@@ -2030,17 +2041,28 @@ static int opal_add_user_to_lr(struct opal_dev *dev,
return ret;
}
static int opal_reverttper(struct opal_dev *dev, struct opal_key *opal)
static int opal_reverttper(struct opal_dev *dev, struct opal_key *opal, bool psid)
{
/* controller will terminate session */
const struct opal_step revert_steps[] = {
{ start_SIDASP_opal_session, opal },
{ revert_tper, } /* controller will terminate session */
{ revert_tper, }
};
const struct opal_step psid_revert_steps[] = {
{ start_PSID_opal_session, opal },
{ revert_tper, }
};
int ret;
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev);
ret = execute_steps(dev, revert_steps, ARRAY_SIZE(revert_steps));
if (psid)
ret = execute_steps(dev, psid_revert_steps,
ARRAY_SIZE(psid_revert_steps));
else
ret = execute_steps(dev, revert_steps,
ARRAY_SIZE(revert_steps));
mutex_unlock(&dev->dev_lock);
/*
......@@ -2280,7 +2302,7 @@ int sed_ioctl(struct opal_dev *dev, unsigned int cmd, void __user *arg)
ret = opal_activate_user(dev, p);
break;
case IOC_OPAL_REVERT_TPR:
ret = opal_reverttper(dev, p);
ret = opal_reverttper(dev, p, false);
break;
case IOC_OPAL_LR_SETUP:
ret = opal_setup_locking_range(dev, p);
......@@ -2297,6 +2319,9 @@ int sed_ioctl(struct opal_dev *dev, unsigned int cmd, void __user *arg)
case IOC_OPAL_SECURE_ERASE_LR:
ret = opal_secure_erase_locking_range(dev, p);
break;
case IOC_OPAL_PSID_REVERT_TPR:
ret = opal_reverttper(dev, p, true);
break;
default:
break;
}
......
......@@ -39,6 +39,7 @@ static inline bool is_sed_ioctl(unsigned int cmd)
case IOC_OPAL_ENABLE_DISABLE_MBR:
case IOC_OPAL_ERASE_LR:
case IOC_OPAL_SECURE_ERASE_LR:
case IOC_OPAL_PSID_REVERT_TPR:
return true;
}
return false;
......
......@@ -107,5 +107,6 @@ struct opal_mbr_data {
#define IOC_OPAL_ENABLE_DISABLE_MBR _IOW('p', 229, struct opal_mbr_data)
#define IOC_OPAL_ERASE_LR _IOW('p', 230, struct opal_session_info)
#define IOC_OPAL_SECURE_ERASE_LR _IOW('p', 231, struct opal_session_info)
#define IOC_OPAL_PSID_REVERT_TPR _IOW('p', 232, struct opal_key)
#endif /* _UAPI_SED_OPAL_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment