linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [for-linus][PATCH 0/3] tracing: Fixes to 5.16
@ 2021-11-13 13:13 Steven Rostedt
  2021-11-13 13:13 ` [for-linus][PATCH 1/3] tracing/osnoise: Make osnoise_instances static Steven Rostedt
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Steven Rostedt @ 2021-11-13 13:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton


Three tracing fixes:

 - Make local osnoise_instances static

 - Copy just actual size of histogram strings

 - Properly check missing operands in histogram expressions

  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
for-next

Head SHA1: 1cab6bce42e62bba2ff2c2370d139618c1828b42


Daniel Bristot de Oliveira (1):
      tracing/osnoise: Make osnoise_instances static

Kalesh Singh (1):
      tracing/histogram: Fix check for missing operands in an expression

Masami Hiramatsu (1):
      tracing/histogram: Do not copy the fixed-size char array field over the field size

----
 kernel/trace/trace_events_hist.c | 12 +++++++-----
 kernel/trace/trace_osnoise.c     |  3 ++-
 2 files changed, 9 insertions(+), 6 deletions(-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [for-linus][PATCH 1/3] tracing/osnoise: Make osnoise_instances static
  2021-11-13 13:13 [for-linus][PATCH 0/3] tracing: Fixes to 5.16 Steven Rostedt
@ 2021-11-13 13:13 ` Steven Rostedt
  2021-11-13 13:13 ` [for-linus][PATCH 2/3] tracing/histogram: Do not copy the fixed-size char array field over the field size Steven Rostedt
  2021-11-13 13:13 ` [for-linus][PATCH 3/3] tracing/histogram: Fix check for missing operands in an expression Steven Rostedt
  2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2021-11-13 13:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Ingo Molnar, kernel test robot,
	Daniel Bristot de Oliveira

From: Daniel Bristot de Oliveira <bristot@kernel.org>

Make the struct list_head osnoise_instances definition static.

Link: https://lore.kernel.org/all/202111120052.ZuikQSJi-lkp@intel.com/
Link: https://lkml.kernel.org/r/d001f0eeac66e2b2eeec7d2a15e9e7abede0453a.1636667971.git.bristot@kernel.org

Cc: Ingo Molnar <mingo@redhat.com>
Fixes: dae181349f1e ("tracing/osnoise: Support a list of trace_array *tr")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/trace_osnoise.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
index 3e4a1651e329..7520d43aed55 100644
--- a/kernel/trace/trace_osnoise.c
+++ b/kernel/trace/trace_osnoise.c
@@ -55,7 +55,8 @@ struct osnoise_instance {
 	struct list_head	list;
 	struct trace_array	*tr;
 };
-struct list_head osnoise_instances;
+
+static struct list_head osnoise_instances;
 
 static bool osnoise_has_registered_instances(void)
 {
-- 
2.33.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [for-linus][PATCH 2/3] tracing/histogram: Do not copy the fixed-size char array field over the field size
  2021-11-13 13:13 [for-linus][PATCH 0/3] tracing: Fixes to 5.16 Steven Rostedt
  2021-11-13 13:13 ` [for-linus][PATCH 1/3] tracing/osnoise: Make osnoise_instances static Steven Rostedt
@ 2021-11-13 13:13 ` Steven Rostedt
  2021-11-13 13:13 ` [for-linus][PATCH 3/3] tracing/histogram: Fix check for missing operands in an expression Steven Rostedt
  2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2021-11-13 13:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Masami Hiramatsu

From: Masami Hiramatsu <mhiramat@kernel.org>

Do not copy the fixed-size char array field of the events over
the field size. The histogram treats char array as a string and
there are 2 types of char array in the event, fixed-size and
dynamic string. The dynamic string (__data_loc) field must be
null terminated, but the fixed-size char array field may not
be null terminated (not a string, but just a data).
In that case, histogram can copy the data after the field.
This uses the original field size for fixed-size char array
field to restrict the histogram not to access over the original
field size.

Link: https://lkml.kernel.org/r/163673292822.195747.3696966210526410250.stgit@devnote2

Fixes: 02205a6752f2 (tracing: Add support for 'field variables')
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/trace_events_hist.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 8ff572a31fd3..6a9fa34e2785 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -1953,9 +1953,10 @@ static struct hist_field *create_hist_field(struct hist_trigger_data *hist_data,
 		if (!hist_field->type)
 			goto free;
 
-		if (field->filter_type == FILTER_STATIC_STRING)
+		if (field->filter_type == FILTER_STATIC_STRING) {
 			hist_field->fn = hist_field_string;
-		else if (field->filter_type == FILTER_DYN_STRING)
+			hist_field->size = field->size;
+		} else if (field->filter_type == FILTER_DYN_STRING)
 			hist_field->fn = hist_field_dynstring;
 		else
 			hist_field->fn = hist_field_pstring;
@@ -3025,7 +3026,7 @@ static inline void __update_field_vars(struct tracing_map_elt *elt,
 			char *str = elt_data->field_var_str[j++];
 			char *val_str = (char *)(uintptr_t)var_val;
 
-			strscpy(str, val_str, STR_VAR_LEN_MAX);
+			strscpy(str, val_str, val->size);
 			var_val = (u64)(uintptr_t)str;
 		}
 		tracing_map_set_var(elt, var_idx, var_val);
@@ -4920,7 +4921,7 @@ static void hist_trigger_elt_update(struct hist_trigger_data *hist_data,
 
 				str = elt_data->field_var_str[idx];
 				val_str = (char *)(uintptr_t)hist_val;
-				strscpy(str, val_str, STR_VAR_LEN_MAX);
+				strscpy(str, val_str, hist_field->size);
 
 				hist_val = (u64)(uintptr_t)str;
 			}
-- 
2.33.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [for-linus][PATCH 3/3] tracing/histogram: Fix check for missing operands in an expression
  2021-11-13 13:13 [for-linus][PATCH 0/3] tracing: Fixes to 5.16 Steven Rostedt
  2021-11-13 13:13 ` [for-linus][PATCH 1/3] tracing/osnoise: Make osnoise_instances static Steven Rostedt
  2021-11-13 13:13 ` [for-linus][PATCH 2/3] tracing/histogram: Do not copy the fixed-size char array field over the field size Steven Rostedt
@ 2021-11-13 13:13 ` Steven Rostedt
  2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2021-11-13 13:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Kalesh Singh, Dan Carpenter

From: Kalesh Singh <kaleshsingh@google.com>

If a binary operation is detected while parsing an expression string,
the operand strings are deduced by splitting the experssion string at
the position of the detected binary operator. Both operand strings are
sub-strings (can be empty string) of the expression string but will
never be NULL.

Currently a NULL check is used for missing operands, fix this by
checking for empty strings instead.

Link: https://lkml.kernel.org/r/20211112191324.1302505-1-kaleshsingh@google.com

Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Fixes: 9710b2f341a0 ("tracing: Fix operator precedence for hist triggers expression")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/trace_events_hist.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 6a9fa34e2785..1475d7347fe0 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -2581,7 +2581,8 @@ static struct hist_field *parse_expr(struct hist_trigger_data *hist_data,
 	operand1_str = str;
 	str = sep+1;
 
-	if (!operand1_str || !str)
+	/* Binary operator requires both operands */
+	if (*operand1_str == '\0' || *str == '\0')
 		goto free;
 
 	operand_flags = 0;
-- 
2.33.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-13 13:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-13 13:13 [for-linus][PATCH 0/3] tracing: Fixes to 5.16 Steven Rostedt
2021-11-13 13:13 ` [for-linus][PATCH 1/3] tracing/osnoise: Make osnoise_instances static Steven Rostedt
2021-11-13 13:13 ` [for-linus][PATCH 2/3] tracing/histogram: Do not copy the fixed-size char array field over the field size Steven Rostedt
2021-11-13 13:13 ` [for-linus][PATCH 3/3] tracing/histogram: Fix check for missing operands in an expression Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).