Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:security\keys\trusted-keys\trusted_tpm1.c Create Date:2022-07-28 18:31:34
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:rusted_update - reseal an existing key with new PCR values

Proto:static int trusted_update(struct key *key, struct key_preparsed_payload *prep)

Type:int

Parameter:

TypeParameterName
struct key *key
struct key_preparsed_payload *prep
1059  datalen = Raw datalen
1061  ret = 0
1063  If key_is_negative(key) Then Return -ENOKEY
1065  p = data[0]
1066  If Not migratable Then Return -EPERM
1068  If datalen <= 0 || datalen > 32767 || Not Raw data Then Return -EINVAL
1071  datablob = Allocation memory
1072  If Not datablob Then Return -ENOMEM
1074  new_o = trusted_options_alloc()
1075  If Not new_o Then
1076  ret = -ENOMEM
1077  Go to out
1079  new_p = trusted_payload_alloc(key)
1080  If Not new_p Then
1081  ret = -ENOMEM
1082  Go to out
1085  memcpy(datablob, Raw data , datalen)
1086  datablob[datalen] = '\0'
1087  ret = datablob_parse - parse the keyctl data and fill in the* payload and options structures* On success returns 0, otherwise -EINVAL.
1088  If ret != Opt_update Then
1089  ret = -EINVAL
1090  kzfree - like kfree but zero memory*@p: object to free memory of* The memory of the object @p points to is zeroed before freed.* If @p is %NULL, kzfree() does nothing.* Note: this function zeroes the whole allocated buffer which can be a good
1091  Go to out
1094  If Not keyhandle Then
1095  ret = -EINVAL
1096  kzfree - like kfree but zero memory*@p: object to free memory of* The memory of the object @p points to is zeroed before freed.* If @p is %NULL, kzfree() does nothing.* Note: this function zeroes the whole allocated buffer which can be a good
1097  Go to out
1101  migratable = migratable
1102  key_len = key_len
1103  memcpy(key, key, key_len)
1104  dump_payload(p)
1105  dump_payload(new_p)
1107  ret = Have the TPM seal(encrypt) the symmetric key
1108  If ret < 0 Then
1109  pr_info("trusted_key: key_seal failed (%d)\n", ret)
1110  kzfree - like kfree but zero memory*@p: object to free memory of* The memory of the object @p points to is zeroed before freed.* If @p is %NULL, kzfree() does nothing.* Note: this function zeroes the whole allocated buffer which can be a good
1111  Go to out
1113  If pcrlock Then
1114  ret = Lock a trusted key, by extending a selected PCR.* Prevents a trusted key that is sealed to PCRs from being accessed.* This uses the tpm driver's extend function.
1115  If ret < 0 Then
1116  pr_info("trusted_key: pcrlock failed (%d)\n", ret)
1118  Go to out
1121  rcu_assign_keypointer(key, new_p)
1122  Post an RCU callback to be invoked after the end of an RCU grace* period. But since we have but one CPU, that would be after any* quiescent state.
1123  out :
1124  kzfree - like kfree but zero memory*@p: object to free memory of* The memory of the object @p points to is zeroed before freed.* If @p is %NULL, kzfree() does nothing.* Note: this function zeroes the whole allocated buffer which can be a good
1125  kzfree - like kfree but zero memory*@p: object to free memory of* The memory of the object @p points to is zeroed before freed.* If @p is %NULL, kzfree() does nothing.* Note: this function zeroes the whole allocated buffer which can be a good
1126  Return ret