From: Dan Carpenter <dan.carpenter@linaro.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: mhiramat@kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [bug report] tracing/probes: Support $argN in return probe (kprobe and fprobe)
Date: Tue, 19 Mar 2024 17:39:32 +0300 [thread overview]
Message-ID: <5d0530e2-43f4-4570-85f6-8404d0b3fea9@moroto.mountain> (raw)
In-Reply-To: <20240319101000.4dbe0cc5@gandalf.local.home>
On Tue, Mar 19, 2024 at 10:10:00AM -0400, Steven Rostedt wrote:
> On Tue, 19 Mar 2024 10:19:09 +0300
> Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> > Hello Masami Hiramatsu (Google),
> >
> > Commit 25f00e40ce79 ("tracing/probes: Support $argN in return probe
> > (kprobe and fprobe)") from Mar 4, 2024 (linux-next), leads to the
> > following Smatch static checker warning:
> >
> > kernel/trace/trace_probe.c:856 store_trace_entry_data()
> > error: uninitialized symbol 'val'.
> >
> > kernel/trace/trace_probe.c
> > 846 return;
> > 847
> > 848 for (i = 0; i < earg->size; i++) {
> > 849 struct fetch_insn *code = &earg->code[i];
> > 850
> > 851 switch (code->op) {
> > 852 case FETCH_OP_ARG:
> > 853 val = regs_get_kernel_argument(regs, code->param);
> > 854 break;
> > 855 case FETCH_OP_ST_EDATA:
> > --> 856 *(unsigned long *)((unsigned long)edata + code->offset) = val;
> >
> > Probably the earg->code[i] always has FETCH_OP_ARG before
> > FETCH_OP_ST_EDATA but Smatch isn't smart enough to figure that out...
>
> Looks that way:
>
> case FETCH_OP_END:
> earg->code[i].op = FETCH_OP_ARG;
> earg->code[i].param = argnum;
> earg->code[i + 1].op = FETCH_OP_ST_EDATA;
> earg->code[i + 1].offset = offset;
> return offset;
>
> But probably should still initialize val to zero or have a WARN_ON() if
> that doesn't happen.
>
Most people use the GCC extension to initialize everything to zero so
initializing to zero really has zero cost. I always recomend people to
do it.
regards,
dan carpenter
next prev parent reply other threads:[~2024-03-19 14:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-19 7:19 [bug report] tracing/probes: Support $argN in return probe (kprobe and fprobe) Dan Carpenter
2024-03-19 14:10 ` Steven Rostedt
2024-03-19 14:39 ` Dan Carpenter [this message]
2024-03-20 3:44 ` Masami Hiramatsu
2024-03-20 13:22 ` Steven Rostedt
2024-03-20 8:10 ` [PATCH] tracing: probes: Fix to zero initialize a local variable Masami Hiramatsu (Google)
2024-03-20 13:26 ` Steven Rostedt
2024-03-20 13:27 ` Steven Rostedt
2024-03-20 22:56 ` Masami Hiramatsu
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=5d0530e2-43f4-4570-85f6-8404d0b3fea9@moroto.mountain \
--to=dan.carpenter@linaro.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
/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