From: sashiko-bot@kernel.org
To: "Jiri Pirko" <jiri@resnulli.us>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH RFC v2 10/15] ctlv: Prepare runtime introspection
Date: Fri, 13 Nov 2026 16:24:07 +0000 [thread overview]
Message-ID: <sashiko-outbox-213191@kernel.org> (raw)
In-Reply-To: <20261113155515.2510194-11-jiri@resnulli.us>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] ctlv: premature depth limit in ctlv_introspection_children()
triggers WARN
--
commit 04c73a263bc43bc51c0a09b62604d548973da60c
Author: Jiri Pirko <jiri@resnulli.us>
ctlv: Prepare runtime introspection
This commit adds runtime introspection handlers for registered families,
effective operations, and message schemas through the CTLV root family, and
introduces struct ctlv.
> diff --git a/lib/ctlv/introspection.c b/lib/ctlv/introspection.c
> new file mode 100644
> index 0000000000000..d030debe69e3c
> --- /dev/null
> +++ b/lib/ctlv/introspection.c
[ ... ]
> +/* The members of a fill inherit the optionality of its extension point. */
> +static bool ctlv_introspection_children(struct ctlv_introspection_walk *walk, u32 depth,
> + const struct ctlv_schema_tree *tree, u32 index,
> + bool force_optional)
> +{
> + const struct ctlv_node_schema *node = &tree->node_schemas[index];
> + u32 i;
> +
> + if (WARN_ON_ONCE(depth + 1 >= CTLV_MAX_RECORD_DEPTH)) {
> + /* Deeper than a specification may declare, so unreachable. */
> + walk->error = -EINVAL;
> + return false;
> + }
[ ... ]
> +/* One node, into the record that stands for it. */
> +static bool ctlv_introspection_node(struct ctlv_introspection_walk *walk, u32 depth,
> + const struct ctlv_schema_tree *tree, u32 index)
> +{
> + const struct ctlv_node_schema *node = &tree->node_schemas[index];
> + u32 reenters = 0;
> +
> + if (node->reenters) {
> + reenters = ctlv_introspection_reenters(walk, depth, tree, node);
> + if (!reenters)
> + return false;
> + }
> + if (!ctlv_introspection_node_fields(walk, depth, node, reenters))
> + return false;
> + /*
> + * A node that re-enters a level says so instead of listing that level's
> + * members again, which is what makes unbounded depth describable.
> + */
> + if (!node->reenters && !ctlv_introspection_children(walk, depth, tree, index, false))
> + return false;
> + if (walk->frames[depth].open)
> + ctlv_record_end(&walk->frames[depth].record);
> + return true;
> +}
[ ... ]
> +int ctlv_op_schema_get_query(struct ctlv *ctlv, struct ctlv_op_ctx *ctx,
> + const struct ctlv_cursor *request, struct ctlv_cursor *reply)
> +{
[ ... ]
> + /*
> + * One frame per level the reply may reach, too many for the stack: a
> + * description is one level deeper than the message it describes.
> + */
> + struct ctlv_introspection_frame *frames __free(kfree) =
> + kcalloc(CTLV_MAX_RECORD_DEPTH, sizeof(*frames), GFP_KERNEL);
[Severity: Medium]
Can ctlv_op_schema_get_query() trigger WARN_ON_ONCE() in
ctlv_introspection_children() and fail with -EINVAL on valid schemas near
CTLV_MAX_DECLARED_RECORD_DEPTH?
ctlv_introspection_node() calls ctlv_introspection_children() on every
non-reentering node, including scalar leaves with no children or extension
points, and ctlv_introspection_children() checks depth + 1 >=
CTLV_MAX_RECORD_DEPTH (8) before checking whether the node has any children.
A leaf field inside 6 nested records sits at walk depth 7, so describing it
hits the WARN_ON_ONCE() and returns -EINVAL.
In addition, CTLV_MAX_DECLARED_RECORD_DEPTH (7) counts only record levels,
whereas op-schema-get wraps both the message root (walk->frames[0]) and the
leaf fields of the deepest record in CTLV_SCHEMA_RECORD nodes. A message at
the maximum declared record depth of 7 needs walk depth 8 (9 record levels in
the reply), which exceeds both the kcalloc(CTLV_MAX_RECORD_DEPTH, ...)
allocation and the CTLV_MAX_RECORD_DEPTH limit in ctlv_record_start().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261113155515.2510194-1-jiri@resnulli.us?part=10
next prev parent reply other threads:[~2026-11-13 16:24 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 15:54 [PATCH RFC v2 00/15] ctlv: Add a schema-driven TLV uAPI for character devices Jiri Pirko
2026-11-13 15:55 ` [PATCH RFC v2 01/15] ctlv: Add the schema language and generator Jiri Pirko
2026-11-13 16:23 ` sashiko-bot
2026-11-13 15:55 ` [PATCH RFC v2 02/15] ctlv: Add the UAPI message format and family API Jiri Pirko
2026-11-13 15:55 ` [PATCH RFC v2 03/15] ctlv: Add the root family specification and generated files Jiri Pirko
2026-11-13 15:55 ` [PATCH RFC v2 04/15] Documentation: ctlv: Add userspace ABI Jiri Pirko
2026-11-13 15:55 ` [PATCH RFC v2 05/15] ctlv: Prepare message input handling Jiri Pirko
2026-11-13 15:55 ` [PATCH RFC v2 06/15] ctlv: Prepare blob descriptor validation Jiri Pirko
2026-11-13 15:55 ` [PATCH RFC v2 07/15] ctlv: Prepare schema validation Jiri Pirko
2026-11-13 16:22 ` sashiko-bot
2026-11-13 15:55 ` [PATCH RFC v2 08/15] ctlv: Prepare message output handling Jiri Pirko
2026-11-13 15:55 ` [PATCH RFC v2 09/15] ctlv: Prepare VA blob handling Jiri Pirko
2026-11-13 16:13 ` sashiko-bot
2026-11-13 15:55 ` [PATCH RFC v2 10/15] ctlv: Prepare runtime introspection Jiri Pirko
2026-11-13 16:24 ` sashiko-bot [this message]
2026-11-13 15:55 ` [PATCH RFC v2 11/15] ctlv: Add operation dispatch Jiri Pirko
2026-11-13 16:29 ` sashiko-bot
2026-11-13 15:55 ` [PATCH RFC v2 12/15] ctlv: Add character device nodes Jiri Pirko
2026-11-13 15:55 ` [PATCH RFC v2 13/15] Documentation: ctlv: Describe how to write a family Jiri Pirko
2026-11-13 16:13 ` sashiko-bot
2026-11-13 15:55 ` [PATCH RFC v2 14/15] tools/ctlv: Add the userspace library Jiri Pirko
2026-11-13 16:28 ` sashiko-bot
2026-11-13 15:55 ` [PATCH RFC v2 15/15] tools/ctlv: Add ctlvctl Jiri Pirko
2026-11-13 16:19 ` 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-213191@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.