Re: [PATCH RFC 15/20] attestation: Prepare provider and instance core
From: Jiri Pirko
Date: Wed Nov 04 2026 - 03:23:01 EST
Thu, Oct 29, 2026 at 07:50:20PM +0100, sergii.dmytruk@xxxxxxxxx wrote:
>On Thu, Oct 15, 2026 at 04:50:48PM +0200, Jiri Pirko wrote:
>> From: Jiri Pirko <jiri@xxxxxxxxxx>
[..]
>> +/**
>> + * struct attestation_mr_props - Immutable MR properties.
>> + * @id: provider-unique MR ID
>> + * @name: MR name
>> + * @algorithms: ordered hash algorithms
>
>Why do these need to be sorted? Is it just to make indexing easier?
They don't. Will lift this limitation.
>
>I see that the number of algorithms is also checked on extending. Does
>it mean that a situation when not all PCR banks are extended at the same
>time is considered an invalid one? That may be a problem at least for
>DRTM which may extend only one bank even if several are active.
Great catch, I missed this usecase. Will allow extension of subset
of banks.
>
>> + * @algorithms_count: number of algorithms
>> + * @has_register_index: whether @register_index is valid
>> + * @register_index: native register index
>> + * @readable: MR can be read
>> + * @extendable: MR can be extended
>
>At least with TPMs, whether a PCR can be extended depends on locality,
>so this isn't necessarily a static property. Is this flag expected to
>always be accurate or it would be OK for a provider to declare an
>extendable MR but then deny doing it?
Okay to declare it and return some appropriate error, like -EPERM. Will
document it.
>
>> + */
>> +struct attestation_mr_props {
>> + unsigned int id;
>> + const char *name;
>> + const enum hash_algo *algorithms;
>> + size_t algorithms_count;
>> + bool has_register_index;
>> + unsigned int register_index;
>> + bool readable;
>> + bool extendable;
>> +};
>> +
>> +/**
>> + * struct attestation_evidence_supported_object - Evidence output description.
>> + * @format: evidence format name
>> + * @max_length: maximum output bytes
>> + * @binds_mrs: evidence validity depends on MR state
>> + */
>> +struct attestation_evidence_supported_object {
>> + const char *format;
>> + size_t max_length;
>> + bool binds_mrs;
>> +};
>> +
>> +/**
>> + * struct attestation_evidence_caps - Immutable evidence capabilities.
>> + * @min_challenge_length: minimum challenge bytes
>> + * @max_challenge_length: maximum challenge bytes
>> + * @max_total_output_length: maximum bytes across all objects
>> + * @objects: supported evidence objects
>> + * @objects_count: number of objects
>> + */
>> +struct attestation_evidence_caps {
>> + size_t min_challenge_length;
>> + size_t max_challenge_length;
>> + size_t max_total_output_length;
>> + const struct attestation_evidence_supported_object *objects;
>> + size_t objects_count;
>> +};
>> +
>> +/**
>> + * struct attestation_evidence_object_request - One resolved output object.
>> + * @supported_object: matching capability entry
>> + * @output: resolved output blob
>> + */
>> +struct attestation_evidence_object_request {
>> + const struct attestation_evidence_supported_object *supported_object;
>> + struct ctlv_blob *output;
>> +};
>> +
>> +/**
>> + * struct attestation_evidence_request - Validated evidence request.
>> + * @challenge: challenge bytes
>> + * @challenge_length: challenge length
>> + * @objects: requested output objects
>> + * @objects_count: number of objects
>> + */
>> +struct attestation_evidence_request {
>> + const u8 *challenge;
>> + size_t challenge_length;
>> + const struct attestation_evidence_object_request *objects;
>> + size_t objects_count;
>> +};
>> +
>> +/**
>> + * struct attestation_evidence_result - Provider evidence result.
>> + * @object_lengths: produced length for every requested object
>> + */
>> +struct attestation_evidence_result {
>> + size_t *object_lengths;
>
>No number of objects? That would make this structure more
>self-contained. Copying `objects` from the request would allow passing
>it around to handle results, but there may not be too much value in
>doing it this way.
Not really needed. This struct is only related got evidence_get cb and
it is always used alongside with struct attestation_evidence_request
which has the count. It would be redundant to have it here too.
>
>> +};
>> +
>> +/**
>> + * struct attestation_provider - Immutable provider operations and properties.
>> + * @evidence_get: produce requested evidence
>> + * @mr_read: read one MR
>> + * @mr_extend: extend one MR
>> + * @evidence_caps: evidence capabilities, or NULL
>> + * @mrs: fixed MR properties
>> + * @mrs_count: number of fixed MRs
>> + */
>> +struct attestation_provider {
>> + int (*evidence_get)(struct attestation *att,
>> + const struct attestation_evidence_request *request,
>> + struct attestation_evidence_result *result);
>> + int (*mr_read)(struct attestation *att, unsigned int mr_id,
>> + struct attestation_digest_set *values);
>> + int (*mr_extend)(struct attestation *att, unsigned int mr_id,
>> + const struct attestation_digest_set *values);
>> + const struct attestation_evidence_caps *evidence_caps;
>> + const struct attestation_mr_props *mrs;
>> + size_t mrs_count;
>> +};
>> +
>> +#endif /* _LINUX_ATTESTATION_H */
>> --
>> 2.56.0