Skip to content

Commit

Permalink
block: sed-opal: PSID reverttper capability
Browse files Browse the repository at this point in the history
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.pdf

Signed-off-by: Revanth Rajashekar <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
RevanthRajashekar authored and axboe committed Jun 29, 2019
1 parent fbbe7c8 commit 5e4c7cf
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
33 changes: 29 additions & 4 deletions block/sed-opal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

/*
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions include/linux/sed-opal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions include/uapi/linux/sed-opal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

0 comments on commit 5e4c7cf

Please sign in to comment.