Re: [PATCH] lib/bootconfig: guard xbc_node_compose_key_after() buffer size

From: Steven Rostedt

Date: Tue Mar 17 2026 - 14:12:47 EST


On Tue, 17 Mar 2026 17:37:03 +0000
Josh Law <objecting@xxxxxxxxxxxxx> wrote:

> @@ -313,13 +313,16 @@ int __init xbc_node_compose_key_after(struct xbc_node *root,
> if (!node && root)
> return -EINVAL;
>
> + if (WARN_ON_ONCE(size > INT_MAX))
> + return -EINVAL;
> +
> while (--depth >= 0) {
> node = xbc_nodes + keys[depth];
> ret = snprintf(buf, size, "%s%s", xbc_node_get_data(node),
> depth ? "." : "");
> if (ret < 0)
> return ret;
> - if (ret >= (int)size) {
> + if ((size_t)ret >= size) {

Hmm, if size can't be greater than INT_MAX, this code should be able to
stay the same.

-- Steve


> size = 0;
> } else {
> size -= (size_t)ret;