> diff --git a/kernel/bpf/stream.c b/kernel/bpf/stream.c
> index 0b157ec4e38e..ef5a7b06ffcb 100644
> --- a/kernel/bpf/stream.c
> +++ b/kernel/bpf/stream.c
> @@ -316,17 +316,19 @@ int bpf_stream_stage_printk(struct bpf_stream_stage
> *ss, const char *fmt, ...)
> {
> struct bpf_bprintf_buffers *buf;
> va_list args;
> - int ret;
> + int len, ret;
>
> if (bpf_try_get_buffers(&buf))
> return -EBUSY;
>
> va_start(args, fmt);
> - ret = vsnprintf(buf->buf, ARRAY_SIZE(buf->buf), fmt, args);
> + /* Cap to the written length, excluding the trailing NUL. */
> + len = vscnprintf(buf->buf, ARRAY_SIZE(buf->buf), fmt, args);
> va_end(args);
> - ss->len += ret;
> /* Exclude NULL byte during push. */
> - ret = __bpf_stream_push_str(&ss->log, buf->buf, ret);
> + ret = __bpf_stream_push_str(&ss->log, buf->buf, len);
> + if (!ret)
> + ss->len += len;
This isn't a bug, but with the existing '/* Exclude NULL byte during
push. */' a couple of lines down, does the new comment above vscnprintf()
add anything, or could one of the two be dropped?
> bpf_put_buffers();
> return ret;
> }
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/31874860107