Re: [PATCH v2] tracing/probe: reject empty immediate strings
From: Google
Date: Sun Apr 05 2026 - 21:20:30 EST
On Mon, 6 Apr 2026 10:11:24 +0900
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx> wrote:
> Hi,
>
> On Sat, 4 Apr 2026 09:33:59 +0900
> Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx> 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@xxxxxxxxxx>
>
>
> --
> Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
--
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>