Re: [PATCH v2] tracing/probe: reject empty immediate strings

Masami Hiramatsu
2026-04-06T01:20:23Z

On Mon, 6 Apr 2026 10:11:24 +0900
Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:

> Hi,
>
> On Sat, 4 Apr 2026 09:33:59 +0900
> Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:
>
> > > diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
> > > index e0a5dc86c07e..e1c73065dae5 100644
> > > --- a/kernel/trace/trace_probe.c
> > > +++ b/kernel/trace/trace_probe.c
> > > @@ -1068,7 +1068,7 @@ static int __parse_imm_string(char *str, char **pbuf, int offs)
> > > {
> > > size_t len = strlen(str);
> > >
> > > - if (str[len - 1] != '"') {
>
> It seems that this is not correct fix, because __parse_imm_string()
> is only called from below code:
>
> case '\\': /* Immediate value */
> if (arg[1] == '"') { /* Immediate string */
> ret = __parse_imm_string(arg + 2, &tmp, ctx->offset + 2);
> if (ret)
>
> Thus the call-site already checked the double-quotation.
> This means this if block itself is meaningless.

Nevermind, this fix is correct. But the title is not correct because
we still can specify an empty string (\""), but this rejects non-closed
empty immediate string (\").

Thank you,

>
> Thanks,
>
> > > + if (!len || str[len - 1] != '"') {
> > > trace_probe_log_err(offs + len, IMMSTR_NO_CLOSE);
> > > return -EINVAL;
> > > }
> > > --
> > > 2.50.1 (Apple Git-155)
> > >
> >
> >
> > --
> > Masami Hiramatsu (Google) <mhiramat@kernel.org>
>
>
> --
> Masami Hiramatsu (Google) <mhiramat@kernel.org>