Patch "tracing: Use str_has_prefix() instead of using fixed sizes" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    tracing: Use str_has_prefix() instead of using fixed sizes

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     tracing-use-str_has_prefix-instead-of-using-fixed-sizes.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From stable+bounces-43485-greg=kroah.com@xxxxxxxxxxxxxxx Thu May  9 04:30:44 2024
From: George Guo <dongtai.guo@xxxxxxxxx>
Date: Thu,  9 May 2024 10:29:26 +0800
Subject: tracing: Use str_has_prefix() instead of using fixed sizes
To: gregkh@xxxxxxxxxxxxxxxxxxx, rostedt@xxxxxxxxxxx, mhiramat@xxxxxxxxxx, tom.zanussi@xxxxxxxxxxxxxxx
Cc: stable@xxxxxxxxxxxxxxx, Namhyung Kim <namhyung@xxxxxxxxxx>, George Guo <guodongtai@xxxxxxxxxx>
Message-ID: <20240509022931.3513365-9-dongtai.guo@xxxxxxxxx>

From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx>

commit b6b2735514bcd70ad1556a33892a636b20ece671 upstream.

There are several instances of strncmp(str, "const", 123), where 123 is the
strlen of the const string to check if "const" is the prefix of str. But
this can be error prone. Use str_has_prefix() instead.

Acked-by: Namhyung Kim <namhyung@xxxxxxxxxx>
Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
Signed-off-by: George Guo <guodongtai@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 kernel/trace/trace.c             |    2 +-
 kernel/trace/trace_events.c      |    2 +-
 kernel/trace/trace_events_hist.c |    2 +-
 kernel/trace/trace_probe.c       |    2 +-
 kernel/trace/trace_stack.c       |    2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -4470,7 +4470,7 @@ static int trace_set_options(struct trac
 
 	cmp = strstrip(option);
 
-	if (strncmp(cmp, "no", 2) == 0) {
+	if (str_has_prefix(cmp, "no")) {
 		neg = 1;
 		cmp += 2;
 	}
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -1249,7 +1249,7 @@ static int f_show(struct seq_file *m, vo
 	 */
 	array_descriptor = strchr(field->type, '[');
 
-	if (!strncmp(field->type, "__data_loc", 10))
+	if (str_has_prefix(field->type, "__data_loc"))
 		array_descriptor = NULL;
 
 	if (!array_descriptor)
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -484,7 +484,7 @@ static int synth_event_define_fields(str
 
 static bool synth_field_signed(char *type)
 {
-	if (strncmp(type, "u", 1) == 0)
+	if (str_has_prefix(type, "u"))
 		return false;
 	if (strcmp(type, "gfp_t") == 0)
 		return false;
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -342,7 +342,7 @@ static int parse_probe_vars(char *arg, c
 			f->fn = t->fetch[FETCH_MTD_retval];
 		else
 			ret = -EINVAL;
-	} else if (strncmp(arg, "stack", 5) == 0) {
+	} else if (str_has_prefix(arg, "stack")) {
 		if (arg[5] == '\0') {
 			if (strcmp(t->name, DEFAULT_FETCH_TYPE_STR))
 				return -EINVAL;
--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -453,7 +453,7 @@ static char stack_trace_filter_buf[COMMA
 
 static __init int enable_stacktrace(char *str)
 {
-	if (strncmp(str, "_filter=", 8) == 0)
+	if (str_has_prefix(str, "_filter="))
 		strncpy(stack_trace_filter_buf, str+8, COMMAND_LINE_SIZE);
 
 	stack_tracer_enabled = 1;


Patches currently in stable-queue which might be from kroah.com@xxxxxxxxxxxxxxx are

queue-4.19/tracing-consolidate-trace_add-remove_event_call-back-to-the-nolock-functions.patch
queue-4.19/tracing-split-up-onmatch-action-data.patch
queue-4.19/tracing-remove-unnecessary-var_ref-destroy-in-track_data_destroy.patch
queue-4.19/tracing-use-str_has_prefix-helper-for-histogram-code.patch
queue-4.19/tracing-simplify-creation-and-deletion-of-synthetic-events.patch
queue-4.19/tracing-refactor-hist-trigger-action-code.patch
queue-4.19/string.h-add-str_has_prefix-helper-function.patch
queue-4.19/tracing-remove-unneeded-synth_event_mutex.patch
queue-4.19/tracing-add-unified-dynamic-event-framework.patch
queue-4.19/tracing-use-dyn_event-framework-for-synthetic-events.patch
queue-4.19/tracing-use-str_has_prefix-instead-of-using-fixed-sizes.patch
queue-4.19/tracing-generalize-hist-trigger-onmax-and-save-action.patch
queue-4.19/tracing-have-the-historgram-use-the-result-of-str_has_prefix-for-len-of-prefix.patch




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux