From: sashiko-bot@kernel.org
To: "Jiri Pirko" <jiri@resnulli.us>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH RFC 17/20] attestation: Add CTLV operation handling
Date: Thu, 15 Oct 2026 15:33:54 +0000 [thread overview]
Message-ID: <sashiko-outbox-173078@kernel.org> (raw)
In-Reply-To: <20261015145053.3664509-18-jiri@resnulli.us>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Critical] core: stack buffer overflow in ctlv_attestation_mr_log_get_query()
- [Medium] core: ctlv_blob memory leak in attestation_evidence_decode_objects()
- [Medium] attestation: missing loop in ctlv_attestation_mr_log_get_query restricts pagination to one entry
--
commit e751f49f55526c0e053324e8d2f25a2d22385dc9
Author: Jiri Pirko <jiri@resnulli.us>
attestation: Add CTLV operation handling
Translate CTLV evidence, MR and journal operations to the provider core and
wire the attestation family into the kernel build.
> diff --git a/drivers/attestation/core/ctlv.c b/drivers/attestation/core/ctlv.c
> new file mode 100644
> index 0000000000000..ff19400843c2c
> --- /dev/null
> +++ b/drivers/attestation/core/ctlv.c
[ ... ]
> +static int
> +attestation_evidence_decode_objects(struct attestation *att, struct ctlv_op_ctx *ctx,
> + const struct ctlv_cursor *request,
> + struct attestation_evidence_request *decoded,
> + struct attestation_evidence_object_request **objects_out)
> +{
[ ... ]
> + ctlv_attestation_evidence_get_evidence_object_for_each(&object, request)
> + {
> + const struct attestation_evidence_supported_object *supported;
> + const char *format;
> + size_t total = 0;
> +
> + format = ctlv_attestation_evidence_get_object_evidence_format_get(&object);
> + supported = attestation_evidence_object_find(caps, format);
> + if (!supported) {
> + kfree(objects);
> + return -EOPNOTSUPP;
> + }
[Severity: Medium]
Will this return leak any successfully resolved blobs from earlier iterations?
On iterations where the index is greater than 0, previous objects have their
output resolved via
ctlv_attestation_evidence_get_object_evidence_data_resolve(). Because this
error path only calls kfree(objects), those earlier ctlv_blob references
seem to be leaked.
> + for (previous = 0; previous < index; previous++)
> + if (objects[previous].supported_object == supported) {
> + kfree(objects);
> + return -EINVAL;
> + }
[Severity: Medium]
Does this face the same memory leak? If a duplicate format is found after some
blobs have already been resolved, it appears the accumulated references in
objects[0] to objects[index - 1] are not freed before returning here.
[ ... ]
> +int ctlv_attestation_mr_log_get_query(void *priv, struct ctlv_op_ctx *ctx,
> + const struct ctlv_cursor *request, struct ctlv_cursor *reply)
> +{
> + struct attestation *att = priv;
> + struct attestation_mr_log_entry *entry;
> + struct ctlv_cursor item, nested;
> + unsigned int ids[256];
> + size_t ids_count = 0, index;
> + unsigned int start, end;
> + unsigned long xa_index;
> + u64 boundary;
> + u64 cursor = ctlv_op_query_cursor(ctx);
> + int ret;
> +
> + ctlv_attestation_mr_log_get_mr_selection_for_each(&item, request)
> + {
> + u64 id = ctlv_attestation_mr_log_get_selection_mr_id_get(&item);
> +
> + if (id > UINT_MAX)
> + return -ERANGE;
> + for (index = 0; index < ids_count; index++)
> + if (ids[index] == id)
> + return -EINVAL;
> + ids[ids_count++] = id;
> + }
[Severity: Critical]
Can this loop overflow the fixed-size ids[] stack array?
If a request contains more than 256 selections, it looks like ids_count
could exceed the size of ids[256] since there isn't a bounds check prior to
appending the id. Would it be possible to add a check to stop writing once
the array is full or return an error?
[ ... ]
> + if (!cursor)
> + return ctlv_op_query_more(ctx, boundary, entry->mr_generation);
> + if (!ctlv_attestation_log_entry_start(reply, &nested))
> + return -EMSGSIZE;
> + ret = attestation_mr_log_entry_encode(&nested, entry);
> + ctlv_nest_end(&nested);
> + if (ret)
> + return ret;
> + entry = xa_find_after(&att->log->entries, &xa_index, end, XA_PRESENT);
> + while (entry && !attestation_log_selected(ids, ids_count, entry->mr_id))
> + entry = xa_find_after(&att->log->entries, &xa_index, end, XA_PRESENT);
> + if (entry)
> + return ctlv_op_query_more(ctx, boundary, entry->mr_generation);
> + return ctlv_op_query_done(ctx, boundary);
> +}
[Severity: Medium]
Is it intentional that this function only encodes one entry per query?
Unlike ctlv_attestation_mr_dump_query() which has a loop over its entries,
this lacks a while (entry) loop wrapping the encode block. It serializes
exactly one entry and then returns ctlv_op_query_more() if more exist,
artificially restricting pagination to a single entry and causing multiple
requests to read the log. Should this iterate until the buffer fills up
(-EMSGSIZE)?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261015145053.3664509-1-jiri@resnulli.us?part=17
next prev parent reply other threads:[~2026-10-15 15:33 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 14:50 [PATCH RFC 00/20] attestation: Add a common subsystem and TDX support Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 01/20] ctlv: Add the schema language and generator Jiri Pirko
2026-10-15 14:58 ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 02/20] ctlv: Add the UAPI wire format and family API Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 03/20] ctlv: Add the root family specification and generated files Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 04/20] Documentation: ctlv: Add userspace ABI Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 05/20] ctlv: Prepare message input handling Jiri Pirko
2026-10-15 15:06 ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 06/20] ctlv: Prepare blob descriptor validation Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 07/20] ctlv: Prepare schema validation Jiri Pirko
2026-10-15 15:14 ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 08/20] ctlv: Prepare message output handling Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 09/20] ctlv: Prepare VA blob handling Jiri Pirko
2026-10-15 15:14 ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 10/20] ctlv: Prepare event queue support Jiri Pirko
2026-10-15 15:22 ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 11/20] ctlv: Prepare runtime introspection Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 12/20] ctlv: Add device and operation dispatch Jiri Pirko
2026-10-15 15:28 ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 13/20] Documentation: ctlv: Describe how to write a family Jiri Pirko
2026-10-15 15:20 ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 14/20] attestation: Add the base family specification and generated files Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 15/20] attestation: Prepare provider and instance core Jiri Pirko
2026-10-15 15:30 ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 16/20] attestation: Prepare measurement register journal Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 17/20] attestation: Add CTLV operation handling Jiri Pirko
2026-10-15 15:33 ` sashiko-bot [this message]
2026-10-15 14:50 ` [PATCH RFC 18/20] tdx-guest: Expose the native attestation service API Jiri Pirko
2026-10-15 15:40 ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 19/20] attestation: Add the TDX family specification and generated files Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 20/20] attestation: Add the TDX family implementation Jiri Pirko
2026-10-15 15:40 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-173078@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=jiri@resnulli.us \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.