Message ID | 168804802668.2028538.4634073314317984220.stgit@mhiramat.roam.corp.google.com (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | [1/2] tracing/probes: Fix to avoid double count of the string length on the array | expand |
On Thu, 29 Jun 2023 23:13:46 +0900 "Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote: > From: Masami Hiramatsu (Google) <mhiramat@kernel.org> > > Fix to exit fetching arguments if an error is detected when storing > strings. Without this fix, if an array is specified with string types > it may point wrong address to store the data. "it may store that data at the wrong address". > > Reported-by: Dan Carpenter <dan.carpenter@linaro.org> > Closes: https://lore.kernel.org/all/8819b154-2ba1-43c3-98a2-cbde20892023@moroto.mountain/ > Fixes: 9b960a38835f ("tracing: probeevent: Unify fetch_insn processing common part") > Cc: stable@vger.kernel.org > Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> > --- > kernel/trace/trace_probe_tmpl.h | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/kernel/trace/trace_probe_tmpl.h b/kernel/trace/trace_probe_tmpl.h > index 4735c5cb76fa..d6f2bf69f9bc 100644 > --- a/kernel/trace/trace_probe_tmpl.h > +++ b/kernel/trace/trace_probe_tmpl.h > @@ -193,6 +193,8 @@ process_fetch_insn_bottom(struct fetch_insn *code, unsigned long val, > default: > return -EILSEQ; > } > + if (ret < 0) > + return ret; Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> -- Steve > code++; > > /* 4th stage: modify stored value if needed */
On Sat, 1 Jul 2023 21:16:17 -0400 Steven Rostedt <rostedt@goodmis.org> wrote: > On Thu, 29 Jun 2023 23:13:46 +0900 > "Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote: > > > From: Masami Hiramatsu (Google) <mhiramat@kernel.org> > > > > Fix to exit fetching arguments if an error is detected when storing > > strings. Without this fix, if an array is specified with string types > > it may point wrong address to store the data. > > "it may store that data at the wrong address". Good catch! Yes, while updating the data location, the remaining length and offset becomes wrong and next array element (string) will be stored in wrong memory address. > > > > > Reported-by: Dan Carpenter <dan.carpenter@linaro.org> > > Closes: https://lore.kernel.org/all/8819b154-2ba1-43c3-98a2-cbde20892023@moroto.mountain/ > > Fixes: 9b960a38835f ("tracing: probeevent: Unify fetch_insn processing common part") > > Cc: stable@vger.kernel.org > > Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> > > --- > > kernel/trace/trace_probe_tmpl.h | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/kernel/trace/trace_probe_tmpl.h b/kernel/trace/trace_probe_tmpl.h > > index 4735c5cb76fa..d6f2bf69f9bc 100644 > > --- a/kernel/trace/trace_probe_tmpl.h > > +++ b/kernel/trace/trace_probe_tmpl.h > > @@ -193,6 +193,8 @@ process_fetch_insn_bottom(struct fetch_insn *code, unsigned long val, > > default: > > return -EILSEQ; > > } > > + if (ret < 0) > > + return ret; > > Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> Thanks! > > -- Steve > > > code++; > > > > /* 4th stage: modify stored value if needed */ >
diff --git a/kernel/trace/trace_probe_tmpl.h b/kernel/trace/trace_probe_tmpl.h index 4735c5cb76fa..d6f2bf69f9bc 100644 --- a/kernel/trace/trace_probe_tmpl.h +++ b/kernel/trace/trace_probe_tmpl.h @@ -193,6 +193,8 @@ process_fetch_insn_bottom(struct fetch_insn *code, unsigned long val, default: return -EILSEQ; } + if (ret < 0) + return ret; code++; /* 4th stage: modify stored value if needed */