2020-05-10 19:44:08 +02:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause */
|
2017-02-10 03:06:16 +01:00
|
|
|
|
|
|
|
/*
|
2015-04-09 17:18:22 +02:00
|
|
|
* Functions for querying, manipulating and locking rollback indices
|
|
|
|
* stored in the TPM NVRAM.
|
|
|
|
*/
|
|
|
|
|
2018-02-27 19:40:52 +01:00
|
|
|
#include <security/tpm/tspi.h>
|
2015-04-09 17:18:22 +02:00
|
|
|
#include <vb2_api.h>
|
|
|
|
|
2018-02-27 19:40:52 +01:00
|
|
|
#include "antirollback.h"
|
|
|
|
|
2019-07-31 08:19:00 +02:00
|
|
|
vb2_error_t vb2ex_tpm_clear_owner(struct vb2_context *ctx)
|
2015-04-09 17:18:22 +02:00
|
|
|
{
|
2018-02-27 19:40:52 +01:00
|
|
|
return VB2_SUCCESS;
|
2015-04-09 17:18:22 +02:00
|
|
|
}
|
|
|
|
|
2019-07-31 08:19:00 +02:00
|
|
|
vb2_error_t antirollback_read_space_firmware(struct vb2_context *ctx)
|
2015-04-09 17:18:22 +02:00
|
|
|
{
|
2019-12-16 19:13:34 +01:00
|
|
|
vb2api_secdata_firmware_create(ctx);
|
2018-02-27 19:40:52 +01:00
|
|
|
return VB2_SUCCESS;
|
2015-04-09 17:18:22 +02:00
|
|
|
}
|
|
|
|
|
2019-07-31 08:19:00 +02:00
|
|
|
vb2_error_t antirollback_write_space_firmware(struct vb2_context *ctx)
|
2015-04-09 17:18:22 +02:00
|
|
|
{
|
2018-02-27 19:40:52 +01:00
|
|
|
return VB2_SUCCESS;
|
2015-04-09 17:18:22 +02:00
|
|
|
}
|
|
|
|
|
2020-04-03 19:56:43 +02:00
|
|
|
vb2_error_t antirollback_read_space_kernel(struct vb2_context *ctx)
|
|
|
|
{
|
2021-05-14 21:33:46 +02:00
|
|
|
/*
|
|
|
|
* The new kernel secdata v1 stores the last read EC hash, and reboots the
|
|
|
|
* device during EC software sync when that hash didn't match the currently
|
|
|
|
* active hash on the EC (this is used with TPM_CR50 to support EC-EFS2 and
|
|
|
|
* pretty much a no-op for other devices). Generally, of course the whole
|
|
|
|
* point of secdata is always that it persists across reboots, but with
|
|
|
|
* MOCK_SECDATA we can't do that. Previously we always happened to somewhat
|
|
|
|
* get away with presenting freshly-reinitialized data for MOCK_SECDATA on
|
|
|
|
* every boot, but with the EC hash feature in secdata v1, that would cause
|
|
|
|
* a reboot loop. The simplest solution is to just pretend we're a secdata
|
|
|
|
* v0 device when using MOCK_SECDATA.
|
|
|
|
*/
|
|
|
|
vb2api_secdata_kernel_create_v0(ctx);
|
2020-04-03 19:56:43 +02:00
|
|
|
return VB2_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
vb2_error_t antirollback_write_space_kernel(struct vb2_context *ctx)
|
|
|
|
{
|
|
|
|
return VB2_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2019-07-31 08:19:00 +02:00
|
|
|
vb2_error_t antirollback_lock_space_firmware(void)
|
2015-04-09 17:18:22 +02:00
|
|
|
{
|
2018-02-27 19:40:52 +01:00
|
|
|
return VB2_SUCCESS;
|
2015-04-09 17:18:22 +02:00
|
|
|
}
|
2016-11-08 08:47:11 +01:00
|
|
|
|
2020-10-16 22:15:59 +02:00
|
|
|
vb2_error_t antirollback_lock_space_mrc_hash(uint32_t index)
|
2016-11-08 08:47:11 +01:00
|
|
|
{
|
2018-02-27 19:40:52 +01:00
|
|
|
return VB2_SUCCESS;
|
2016-11-08 08:47:11 +01:00
|
|
|
}
|
2017-01-27 00:33:01 +01:00
|
|
|
|
2020-10-16 22:15:59 +02:00
|
|
|
vb2_error_t antirollback_read_space_mrc_hash(uint32_t index, uint8_t *data, uint32_t size)
|
2017-01-27 00:33:01 +01:00
|
|
|
{
|
2018-02-27 19:40:52 +01:00
|
|
|
return VB2_SUCCESS;
|
2017-01-27 00:33:01 +01:00
|
|
|
}
|
|
|
|
|
2020-10-16 22:15:59 +02:00
|
|
|
vb2_error_t antirollback_write_space_mrc_hash(uint32_t index, const uint8_t *data,
|
2019-07-31 08:19:00 +02:00
|
|
|
uint32_t size)
|
2017-04-26 07:32:34 +02:00
|
|
|
{
|
|
|
|
return VB2_SUCCESS;
|
|
|
|
}
|