* [PATCH 1/2] tracing/probes: Fix to avoid double count of the string length on the array
[not found] <8819b154-2ba1-43c3-98a2-cbde20892023@moroto.mountain>
@ 2023-06-29 14:13 ` Masami Hiramatsu (Google)
2023-07-02 1:08 ` Steven Rostedt
2023-06-29 14:13 ` [PATCH 2/2] tracing/probes: Fix to exit fetching if an error is detected Masami Hiramatsu (Google)
1 sibling, 1 reply; 6+ messages in thread
From: Masami Hiramatsu (Google) @ 2023-06-29 14:13 UTC (permalink / raw)
To: Steven Rostedt; +Cc: Dan Carpenter, linux-trace-kernel, LKML, Masami Hiramatsu
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
If there is an array is specified with the ustring or symstr, the length of
the strings are accumlated on both of 'ret' and 'total', which means the
length is double counted.
Just set the length to the 'ret' value to aviud double count.
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/all/8819b154-2ba1-43c3-98a2-cbde20892023@moroto.mountain/
Fixes: 88903c464321 ("tracing/probe: Add ustring type for user-space string")
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
kernel/trace/trace_probe_tmpl.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/trace/trace_probe_tmpl.h b/kernel/trace/trace_probe_tmpl.h
index 00707630788d..4735c5cb76fa 100644
--- a/kernel/trace/trace_probe_tmpl.h
+++ b/kernel/trace/trace_probe_tmpl.h
@@ -156,11 +156,11 @@ process_fetch_insn_bottom(struct fetch_insn *code, unsigned long val,
code++;
goto array;
case FETCH_OP_ST_USTRING:
- ret += fetch_store_strlen_user(val + code->offset);
+ ret = fetch_store_strlen_user(val + code->offset);
code++;
goto array;
case FETCH_OP_ST_SYMSTR:
- ret += fetch_store_symstrlen(val + code->offset);
+ ret = fetch_store_symstrlen(val + code->offset);
code++;
goto array;
default:
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] tracing/probes: Fix to exit fetching if an error is detected
[not found] <8819b154-2ba1-43c3-98a2-cbde20892023@moroto.mountain>
2023-06-29 14:13 ` [PATCH 1/2] tracing/probes: Fix to avoid double count of the string length on the array Masami Hiramatsu (Google)
@ 2023-06-29 14:13 ` Masami Hiramatsu (Google)
2023-07-02 1:16 ` Steven Rostedt
1 sibling, 1 reply; 6+ messages in thread
From: Masami Hiramatsu (Google) @ 2023-06-29 14:13 UTC (permalink / raw)
To: Steven Rostedt; +Cc: Dan Carpenter, linux-trace-kernel, LKML, Masami Hiramatsu
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.
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;
code++;
/* 4th stage: modify stored value if needed */
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] tracing/probes: Fix to avoid double count of the string length on the array
2023-06-29 14:13 ` [PATCH 1/2] tracing/probes: Fix to avoid double count of the string length on the array Masami Hiramatsu (Google)
@ 2023-07-02 1:08 ` Steven Rostedt
2023-07-02 12:56 ` Masami Hiramatsu
0 siblings, 1 reply; 6+ messages in thread
From: Steven Rostedt @ 2023-07-02 1:08 UTC (permalink / raw)
To: Masami Hiramatsu (Google); +Cc: Dan Carpenter, linux-trace-kernel, LKML
On Thu, 29 Jun 2023 23:13:37 +0900
"Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:
> From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
>
> If there is an array is specified with the ustring or symstr, the length of
"If there is an array specified with ustring or .." or "If an array is specified with ustring"
I prefer the latter.
> the strings are accumlated on both of 'ret' and 'total', which means the
> length is double counted.
> Just set the length to the 'ret' value to aviud double count.
"avoid"
>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/all/8819b154-2ba1-43c3-98a2-cbde20892023@moroto.mountain/
> Fixes: 88903c464321 ("tracing/probe: Add ustring type for user-space string")
> Cc: stable@vger.kernel.org
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> ---
> kernel/trace/trace_probe_tmpl.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/trace/trace_probe_tmpl.h b/kernel/trace/trace_probe_tmpl.h
> index 00707630788d..4735c5cb76fa 100644
> --- a/kernel/trace/trace_probe_tmpl.h
> +++ b/kernel/trace/trace_probe_tmpl.h
> @@ -156,11 +156,11 @@ process_fetch_insn_bottom(struct fetch_insn *code, unsigned long val,
> code++;
> goto array;
> case FETCH_OP_ST_USTRING:
> - ret += fetch_store_strlen_user(val + code->offset);
> + ret = fetch_store_strlen_user(val + code->offset);
> code++;
> goto array;
> case FETCH_OP_ST_SYMSTR:
> - ret += fetch_store_symstrlen(val + code->offset);
> + ret = fetch_store_symstrlen(val + code->offset);
Other than the above,
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
-- Steve
> code++;
> goto array;
> default:
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] tracing/probes: Fix to exit fetching if an error is detected
2023-06-29 14:13 ` [PATCH 2/2] tracing/probes: Fix to exit fetching if an error is detected Masami Hiramatsu (Google)
@ 2023-07-02 1:16 ` Steven Rostedt
2023-07-02 13:46 ` Masami Hiramatsu
0 siblings, 1 reply; 6+ messages in thread
From: Steven Rostedt @ 2023-07-02 1:16 UTC (permalink / raw)
To: Masami Hiramatsu (Google); +Cc: Dan Carpenter, linux-trace-kernel, LKML
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 */
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] tracing/probes: Fix to avoid double count of the string length on the array
2023-07-02 1:08 ` Steven Rostedt
@ 2023-07-02 12:56 ` Masami Hiramatsu
0 siblings, 0 replies; 6+ messages in thread
From: Masami Hiramatsu @ 2023-07-02 12:56 UTC (permalink / raw)
To: Steven Rostedt; +Cc: Dan Carpenter, linux-trace-kernel, LKML
On Sat, 1 Jul 2023 21:08:40 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:
> On Thu, 29 Jun 2023 23:13:37 +0900
> "Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:
>
> > From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> >
> > If there is an array is specified with the ustring or symstr, the length of
>
> "If there is an array specified with ustring or .." or "If an array is specified with ustring"
>
> I prefer the latter.
>
> > the strings are accumlated on both of 'ret' and 'total', which means the
> > length is double counted.
> > Just set the length to the 'ret' value to aviud double count.
>
> "avoid"
>
> >
> > Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> > Closes: https://lore.kernel.org/all/8819b154-2ba1-43c3-98a2-cbde20892023@moroto.mountain/
> > Fixes: 88903c464321 ("tracing/probe: Add ustring type for user-space string")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> > ---
> > kernel/trace/trace_probe_tmpl.h | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/kernel/trace/trace_probe_tmpl.h b/kernel/trace/trace_probe_tmpl.h
> > index 00707630788d..4735c5cb76fa 100644
> > --- a/kernel/trace/trace_probe_tmpl.h
> > +++ b/kernel/trace/trace_probe_tmpl.h
> > @@ -156,11 +156,11 @@ process_fetch_insn_bottom(struct fetch_insn *code, unsigned long val,
> > code++;
> > goto array;
> > case FETCH_OP_ST_USTRING:
> > - ret += fetch_store_strlen_user(val + code->offset);
> > + ret = fetch_store_strlen_user(val + code->offset);
> > code++;
> > goto array;
> > case FETCH_OP_ST_SYMSTR:
> > - ret += fetch_store_symstrlen(val + code->offset);
> > + ret = fetch_store_symstrlen(val + code->offset);
>
> Other than the above,
>
> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Thanks! I'll resend it with fixes.
>
> -- Steve
>
>
> > code++;
> > goto array;
> > default:
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] tracing/probes: Fix to exit fetching if an error is detected
2023-07-02 1:16 ` Steven Rostedt
@ 2023-07-02 13:46 ` Masami Hiramatsu
0 siblings, 0 replies; 6+ messages in thread
From: Masami Hiramatsu @ 2023-07-02 13:46 UTC (permalink / raw)
To: Steven Rostedt; +Cc: Dan Carpenter, linux-trace-kernel, LKML
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 */
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-07-02 13:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <8819b154-2ba1-43c3-98a2-cbde20892023@moroto.mountain>
2023-06-29 14:13 ` [PATCH 1/2] tracing/probes: Fix to avoid double count of the string length on the array Masami Hiramatsu (Google)
2023-07-02 1:08 ` Steven Rostedt
2023-07-02 12:56 ` Masami Hiramatsu
2023-06-29 14:13 ` [PATCH 2/2] tracing/probes: Fix to exit fetching if an error is detected Masami Hiramatsu (Google)
2023-07-02 1:16 ` Steven Rostedt
2023-07-02 13:46 ` Masami Hiramatsu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®