@@ -11,6 +11,7 @@ typedef struct {
11
11
UINTN measuredcount = 0 ;
12
12
VARIABLE_RECORD * measureddata = NULL ;
13
13
static BOOLEAN tpm_defective = FALSE;
14
+ static BOOLEAN log_full_already_warned = FALSE;
14
15
15
16
static BOOLEAN tpm_present (efi_tpm_protocol_t * tpm )
16
17
{
@@ -108,6 +109,16 @@ static EFI_STATUS tpm_locate_protocol(efi_tpm_protocol_t **tpm,
108
109
return EFI_NOT_FOUND ;
109
110
}
110
111
112
+ static void warn_first_log_full (void )
113
+ {
114
+ if (!log_full_already_warned ) {
115
+ perror (L"TPM extend operation occurred, but the event could"
116
+ " not be written to one or more event logs. Applications"
117
+ " reliant on a valid event log will not function.\n" );
118
+ log_full_already_warned = TRUE;
119
+ }
120
+ }
121
+
111
122
static EFI_STATUS cc_log_event_raw (EFI_PHYSICAL_ADDRESS buf , UINTN size ,
112
123
UINT8 pcr , const CHAR8 * log , UINTN logsize ,
113
124
UINT32 type , BOOLEAN is_pe_image )
@@ -143,6 +154,14 @@ static EFI_STATUS cc_log_event_raw(EFI_PHYSICAL_ADDRESS buf, UINTN size,
143
154
CopyMem (event -> Event , (VOID * )log , logsize );
144
155
efi_status = cc -> hash_log_extend_event (cc , flags , buf , (UINT64 )size ,
145
156
event );
157
+ /* Per spec: The extend operation occurred, but the event could
158
+ * not be written to one or more event logs. We can still safely
159
+ * boot in this case, but also show a warning to let the user know.
160
+ */
161
+ if (efi_status == EFI_VOLUME_FULL ) {
162
+ warn_first_log_full ();
163
+ efi_status = EFI_SUCCESS ;
164
+ }
146
165
FreePool (event );
147
166
return efi_status ;
148
167
}
@@ -201,11 +220,19 @@ static EFI_STATUS tpm_log_event_raw(EFI_PHYSICAL_ADDRESS buf, UINTN size,
201
220
*/
202
221
efi_status = tpm2 -> hash_log_extend_event (tpm2 ,
203
222
PE_COFF_IMAGE , buf , (UINT64 ) size , event );
223
+ if (efi_status == EFI_VOLUME_FULL ) {
224
+ warn_first_log_full ();
225
+ efi_status = EFI_SUCCESS ;
226
+ }
204
227
}
205
228
206
229
if (!hash || EFI_ERROR (efi_status )) {
207
230
efi_status = tpm2 -> hash_log_extend_event (tpm2 ,
208
231
0 , buf , (UINT64 ) size , event );
232
+ if (efi_status == EFI_VOLUME_FULL ) {
233
+ warn_first_log_full ();
234
+ efi_status = EFI_SUCCESS ;
235
+ }
209
236
}
210
237
FreePool (event );
211
238
return efi_status ;
@@ -239,10 +266,18 @@ static EFI_STATUS tpm_log_event_raw(EFI_PHYSICAL_ADDRESS buf, UINTN size,
239
266
CopyMem (event -> digest , hash , sizeof (event -> digest ));
240
267
efi_status = tpm -> log_extend_event (tpm , 0 , 0 ,
241
268
TPM_ALG_SHA , event , & eventnum , & lastevent );
269
+ if (efi_status == EFI_VOLUME_FULL ) {
270
+ warn_first_log_full ();
271
+ efi_status = EFI_SUCCESS ;
272
+ }
242
273
} else {
243
274
efi_status = tpm -> log_extend_event (tpm , buf ,
244
275
(UINT64 )size , TPM_ALG_SHA , event , & eventnum ,
245
276
& lastevent );
277
+ if (efi_status == EFI_VOLUME_FULL ) {
278
+ warn_first_log_full ();
279
+ efi_status = EFI_SUCCESS ;
280
+ }
246
281
}
247
282
if (efi_status == EFI_UNSUPPORTED ) {
248
283
perror (L"Could not write TPM event: %r. Considering "
0 commit comments