Skip to content

Commit 5e4c7cf

Browse files
RevanthRajashekaraxboe
authored andcommitted
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.pdf Signed-off-by: Revanth Rajashekar <revanth.rajashekar@intel.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent fbbe7c8 commit 5e4c7cf

3 files changed

Lines changed: 31 additions & 4 deletions

File tree

‎block/sed-opal.c‎

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,7 @@ static int start_generic_opal_session(struct opal_dev *dev,
13071307
break;
13081308
case OPAL_ADMIN1_UID:
13091309
case OPAL_SID_UID:
1310+
case OPAL_PSID_UID:
13101311
add_token_u8(&err, dev, OPAL_STARTNAME);
13111312
add_token_u8(&err, dev, 0); /* HostChallenge */
13121313
add_token_bytestring(&err, dev, key, key_len);
@@ -1367,6 +1368,16 @@ static int start_admin1LSP_opal_session(struct opal_dev *dev, void *data)
13671368
key->key, key->key_len);
13681369
}
13691370

1371+
static int start_PSID_opal_session(struct opal_dev *dev, void *data)
1372+
{
1373+
const struct opal_key *okey = data;
1374+
1375+
return start_generic_opal_session(dev, OPAL_PSID_UID,
1376+
OPAL_ADMINSP_UID,
1377+
okey->key,
1378+
okey->key_len);
1379+
}
1380+
13701381
static int start_auth_opal_session(struct opal_dev *dev, void *data)
13711382
{
13721383
struct opal_session_info *session = data;
@@ -2030,17 +2041,28 @@ static int opal_add_user_to_lr(struct opal_dev *dev,
20302041
return ret;
20312042
}
20322043

2033-
static int opal_reverttper(struct opal_dev *dev, struct opal_key *opal)
2044+
static int opal_reverttper(struct opal_dev *dev, struct opal_key *opal, bool psid)
20342045
{
2046+
/* controller will terminate session */
20352047
const struct opal_step revert_steps[] = {
20362048
{ start_SIDASP_opal_session, opal },
2037-
{ revert_tper, } /* controller will terminate session */
2049+
{ revert_tper, }
20382050
};
2051+
const struct opal_step psid_revert_steps[] = {
2052+
{ start_PSID_opal_session, opal },
2053+
{ revert_tper, }
2054+
};
2055+
20392056
int ret;
20402057

20412058
mutex_lock(&dev->dev_lock);
20422059
setup_opal_dev(dev);
2043-
ret = execute_steps(dev, revert_steps, ARRAY_SIZE(revert_steps));
2060+
if (psid)
2061+
ret = execute_steps(dev, psid_revert_steps,
2062+
ARRAY_SIZE(psid_revert_steps));
2063+
else
2064+
ret = execute_steps(dev, revert_steps,
2065+
ARRAY_SIZE(revert_steps));
20442066
mutex_unlock(&dev->dev_lock);
20452067

20462068
/*
@@ -2280,7 +2302,7 @@ int sed_ioctl(struct opal_dev *dev, unsigned int cmd, void __user *arg)
22802302
ret = opal_activate_user(dev, p);
22812303
break;
22822304
case IOC_OPAL_REVERT_TPR:
2283-
ret = opal_reverttper(dev, p);
2305+
ret = opal_reverttper(dev, p, false);
22842306
break;
22852307
case IOC_OPAL_LR_SETUP:
22862308
ret = opal_setup_locking_range(dev, p);
@@ -2297,6 +2319,9 @@ int sed_ioctl(struct opal_dev *dev, unsigned int cmd, void __user *arg)
22972319
case IOC_OPAL_SECURE_ERASE_LR:
22982320
ret = opal_secure_erase_locking_range(dev, p);
22992321
break;
2322+
case IOC_OPAL_PSID_REVERT_TPR:
2323+
ret = opal_reverttper(dev, p, true);
2324+
break;
23002325
default:
23012326
break;
23022327
}

‎include/linux/sed-opal.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ static inline bool is_sed_ioctl(unsigned int cmd)
3939
case IOC_OPAL_ENABLE_DISABLE_MBR:
4040
case IOC_OPAL_ERASE_LR:
4141
case IOC_OPAL_SECURE_ERASE_LR:
42+
case IOC_OPAL_PSID_REVERT_TPR:
4243
return true;
4344
}
4445
return false;

‎include/uapi/linux/sed-opal.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,6 @@ struct opal_mbr_data {
107107
#define IOC_OPAL_ENABLE_DISABLE_MBR _IOW('p', 229, struct opal_mbr_data)
108108
#define IOC_OPAL_ERASE_LR _IOW('p', 230, struct opal_session_info)
109109
#define IOC_OPAL_SECURE_ERASE_LR _IOW('p', 231, struct opal_session_info)
110+
#define IOC_OPAL_PSID_REVERT_TPR _IOW('p', 232, struct opal_key)
110111

111112
#endif /* _UAPI_SED_OPAL_H */

0 commit comments

Comments
 (0)