Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jiri Pirko" <jiri@resnulli.us>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH RFC v2 07/15] ctlv: Prepare schema validation
Date: Fri, 13 Nov 2026 16:22:29 +0000	[thread overview]
Message-ID: <sashiko-outbox-213187@kernel.org> (raw)
In-Reply-To: <20261113155515.2510194-8-jiri@resnulli.us>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] ctlv: ctlv_schema_min_len() enforces record depth limit on
  leaf nodes
--

commit f7e5c872905b61fc69a0da34a919232ff36227be
Author: Jiri Pirko <jiri@resnulli.us>

ctlv: Prepare schema validation

This commit adds generated-schema walking, message validation, and request
indexing for CTLV schemas.

> diff --git a/lib/ctlv/schema.c b/lib/ctlv/schema.c
> new file mode 100644
> index 0000000000000..8ff3c7c5b5fe0
> --- /dev/null
> +++ b/lib/ctlv/schema.c
> @@ -0,0 +1,1092 @@
[ ... ]
> +/* Buffer length that the largest indivisible leaf and its records need. */
> +static u64 ctlv_schema_min_len(struct ctlv_schema_length_walk *walk,
> +			       const struct ctlv_schema_tree *tree, u32 index, u32 above, u32 depth)
> +{
> +	const struct ctlv_node_schema *node = &tree->node_schemas[index];
> +	bool has_children = false;
> +	u64 deepest = 0;
> +	u32 i;
> +
> +	if (depth > CTLV_MAX_DECLARED_RECORD_DEPTH) {
> +		walk->bad = true;
> +		return 0;
> +	}
> +
> +	for (i = 0; i < node->children_count; i++) {
> +		u32 child = node->first_child + i;
> +
> +		has_children = true;
> +		deepest = max(deepest,
> +			      ctlv_schema_min_len(walk, tree, child,
> +						  above + sizeof(struct ctlv_hdr), depth + 1));
> +	}
> +
> +	for (i = 0; i < tree->ext_schemas_count; i++) {
> +		const struct ctlv_ext_schema *ext_schema = &tree->ext_schemas[i];
> +		const struct ctlv_ext_fill_schema *fill_schema;
> +		const struct ctlv_node_schema *root;
> +		u32 member;
> +
> +		if (ext_schema->node != index)
> +			continue;
> +		fill_schema =
> +			ctlv_schema_fill(walk->family, ext_schema->family_id, ext_schema->ext_id);
> +		if (!fill_schema)
> +			continue;
> +		root = &fill_schema->members.node_schemas[0];
> +		for (member = 0; member < root->children_count; member++) {
> +			has_children = true;
> +			deepest = max(deepest, ctlv_schema_min_len(walk, &fill_schema->members,
> +								   root->first_child + member,
> +								   above + sizeof(struct ctlv_hdr),
> +								   depth + 1));
> +		}
> +	}
> +
> +	if (has_children)
> +		return deepest;
> +	/* An empty root is a message of its own header alone. */
> +	if (!index)
> +		return above + sizeof(struct ctlv_hdr);
> +	return above + ALIGN(ctlv_schema_tlv_max_len(walk, tree, index, depth), CTLV_ALIGNTO);
> +}

[Severity: Medium]
Does ctlv_schema_min_len() reject valid leaf fields inside a record at
CTLV_MAX_DECLARED_RECORD_DEPTH?

Unlike ctlv_schema_children_max_len(), which is only entered for
CTLV_SCHEMA_RECORD nodes, ctlv_schema_min_len() recurses into every child
and extension fill member with depth + 1 and checks depth >
CTLV_MAX_DECLARED_RECORD_DEPTH at entry for all nodes.  When a non-reentering
query reply has a record at depth CTLV_MAX_DECLARED_RECORD_DEPTH (7), its
leaf children are visited at depth 8, setting walk->bad = true and causing
ctlv_schema_op_sizes() to fail with -EINVAL.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261113155515.2510194-1-jiri@resnulli.us?part=7

  reply	other threads:[~2026-11-13 16:22 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 [this message]
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
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-213187@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox