return r;
r = tpm2_nvpcr_initialize(c, /* session= */ NULL, name, &anchor_secret);
+ if (r == -ENOBUFS)
+ return r; /* NV space exhausted; let caller handle gracefully */
if (r < 0)
return log_error_errno(r, "Failed to extend NvPCR index '%s' with anchor secret: %m", name);
r = extend_nvpcr_now(p.nvpcr, extend_iovec->iov_base, extend_iovec->iov_len, p.event_type);
if (IN_SET(r, -ENOENT, -ENODEV))
return sd_varlink_error(link, "io.systemd.PCRExtend.NoSuchNvPCR", NULL);
+ if (r == -ENOBUFS)
+ return sd_varlink_error(link, "io.systemd.PCRExtend.NvPCRSpaceExhausted", NULL);
} else
r = extend_pcr_now(INDEX_TO_MASK(uint32_t, p.pcr), extend_iovec->iov_base, extend_iovec->iov_len, p.event_type);
if (r < 0)
log_notice_errno(r, "TPM2 cannot be used for measurement (no usable PCR bank, missing device, or missing crypto support), skipping gracefully.");
return EXIT_SUCCESS;
}
+ if (arg_graceful && r == -ENOBUFS) {
+ log_notice_errno(r, "TPM NV index space is exhausted, NvPCR '%s' could not be initialized, skipping gracefully.", arg_nvpcr_name);
+ return EXIT_SUCCESS;
+ }
if (r < 0)
return r;
&public_info,
&new_handle->esys_handle);
if (rc == TPM2_RC_NV_SPACE)
- return log_debug_errno(SYNTHETIC_ERRNO(ENOSPC),
+ return log_debug_errno(SYNTHETIC_ERRNO(ENOBUFS),
"NV index space on TPM exhausted, cannot allocate NvPCR.");
if (rc == TPM2_RC_NV_DEFINED) {
log_debug("NV index 0x%" PRIu32 " already registered.", nv_index);
SD_VARLINK_DEFINE_INPUT_BY_TYPE(eventType, EventType, SD_VARLINK_NULLABLE));
static SD_VARLINK_DEFINE_ERROR(NoSuchNvPCR);
+static SD_VARLINK_DEFINE_ERROR(NvPCRSpaceExhausted);
SD_VARLINK_DEFINE_INTERFACE(
io_systemd_PCRExtend,
&vl_method_Extend,
SD_VARLINK_SYMBOL_COMMENT("Event type to store in event log"),
&vl_type_EventType,
- &vl_error_NoSuchNvPCR);
+ &vl_error_NoSuchNvPCR,
+ SD_VARLINK_SYMBOL_COMMENT("Space for NV indexes/NvPCRs exhausted, cannot measure."),
+ &vl_error_NvPCRSpaceExhausted);
LOG_MESSAGE("The TPM does not correctly support NV indexes in NT_EXTEND mode, unable to allocate NvPCR '%s': %m", name),
LOG_MESSAGE_ID(SD_MESSAGE_TPM_NVPCR_UNSUPPORTED_STR));
}
- if (r == -ENOSPC) {
+ if (r == -ENOBUFS) {
/* The TPM's NV index space is exhausted. Remember this so we skip the remaining (less
* important) NvPCRs, and report it gracefully at the end rather than failing the boot.
* Logged at notice level, not error. */
* SuccessExitStatus= in the service unit file. */
if (ret == -EOPNOTSUPP)
return EX_UNAVAILABLE; /* e.g. no NvPCR support in TPM */
- if (ret == -ENOSPC)
+ if (ret == -ENOBUFS)
return EX_CANTCREAT; /* NV index space on TPM exhausted */
return ret;