diff mbox series

[1/2] tracing/probes: Fix to avoid double count of the string length on the array

Message ID 168804801788.2028538.4620519547242506783.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

Commit Message

Masami Hiramatsu (Google) June 29, 2023, 2:13 p.m. UTC
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(-)

Comments

Steven Rostedt July 2, 2023, 1:08 a.m. UTC | #1
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:
Masami Hiramatsu (Google) July 2, 2023, 12:56 p.m. UTC | #2
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:
>
diff mbox series

Patch

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: