linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [for-linus][PATCH 00/10] tracing: Fixes for 5.17-rc1
@ 2022-01-28 16:18 Steven Rostedt
  2022-01-28 16:18 ` [for-linus][PATCH 01/10] ftrace: Have architectures opt-in for mcount build time sorting Steven Rostedt
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Steven Rostedt @ 2022-01-28 16:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Kees Cook, Masami Hiramatsu,
	Shuah Khan, Tom Zanussi, Xiaoke Wang

Tracing fixes for 5.17-rc1:

 - Limit mcount build time sorting to only those archs that
   we know it works for.

 - Fix memory leak in error path of historgam setup

 - Fix and clean up rel_loc array out of bounds issue

 - tools/rtla documentation fixes

 - Fix issues with histogram logic

  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
ftrace/urgent

Head SHA1: 67ab5eb71b37b55f7c5522d080a1b42823351776


Kees Cook (1):
      tracing/perf: Avoid -Warray-bounds warning for __rel_loc macro

Masami Hiramatsu (1):
      tracing: Avoid -Warray-bounds warning for __rel_loc macro

Shuah Khan (2):
      rtla: Make doc build optional
      tools/tracing: Update Makefile to build rtla

Steven Rostedt (Google) (1):
      ftrace: Have architectures opt-in for mcount build time sorting

Tom Zanussi (4):
      tracing: Fix smatch warning for null glob in event_hist_trigger_parse()
      tracing: Fix smatch warning for do while check in event_hist_trigger_parse()
      tracing: Propagate is_signed to expression
      tracing: Don't inc err_log entry count if entry allocation fails

Xiaoke Wang (1):
      tracing/histogram: Fix a potential memory leak for kstrdup()

----
 arch/arm/Kconfig                 |  1 +
 arch/x86/Kconfig                 |  1 +
 include/trace/perf.h             |  5 +++--
 include/trace/trace_events.h     |  9 +++++----
 kernel/trace/Kconfig             |  8 +++++++-
 kernel/trace/trace.c             |  3 ++-
 kernel/trace/trace_events_hist.c | 10 ++++++++--
 scripts/Makefile                 |  2 +-
 tools/tracing/Makefile           | 18 ++++++++++++++----
 tools/tracing/rtla/Makefile      |  2 +-
 10 files changed, 43 insertions(+), 16 deletions(-)

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

* [for-linus][PATCH 01/10] ftrace: Have architectures opt-in for mcount build time sorting
  2022-01-28 16:18 [for-linus][PATCH 00/10] tracing: Fixes for 5.17-rc1 Steven Rostedt
@ 2022-01-28 16:18 ` Steven Rostedt
  2022-01-28 16:18 ` [for-linus][PATCH 02/10] tracing/histogram: Fix a potential memory leak for kstrdup() Steven Rostedt
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Steven Rostedt @ 2022-01-28 16:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Russell King, Yinan Liu,
	Ard Biesheuvel, Kees Cook, Sachin Sant, Mark Rutland

From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

First S390 complained that the sorting of the mcount sections at build
time caused the kernel to crash on their architecture. Now PowerPC is
complaining about it too. And also ARM64 appears to be having issues.

It may be necessary to also update the relocation table for the values
in the mcount table. Not only do we have to sort the table, but also
update the relocations that may be applied to the items in the table.

If the system is not relocatable, then it is fine to sort, but if it is,
some architectures may have issues (although x86 does not as it shifts all
addresses the same).

Add a HAVE_BUILDTIME_MCOUNT_SORT that an architecture can set to say it is
safe to do the sorting at build time.

Also update the config to compile in build time sorting in the sorttable
code in scripts/ to depend on CONFIG_BUILDTIME_MCOUNT_SORT.

Link: https://lore.kernel.org/all/944D10DA-8200-4BA9-8D0A-3BED9AA99F82@linux.ibm.com/
Link: https://lkml.kernel.org/r/20220127153821.3bc1ac6e@gandalf.local.home

Cc: Ingo Molnar <mingo@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Yinan Liu <yinan@linux.alibaba.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Reported-by: Sachin Sant <sachinp@linux.ibm.com>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Mark Rutland <mark.rutland@arm.com> [arm64]
Tested-by: Sachin Sant <sachinp@linux.ibm.com>
Fixes: 72b3942a173c ("scripts: ftrace - move the sort-processing in ftrace_init")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 arch/arm/Kconfig     | 1 +
 arch/x86/Kconfig     | 1 +
 kernel/trace/Kconfig | 8 +++++++-
 scripts/Makefile     | 2 +-
 4 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index fabe39169b12..4c97cb40eebb 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -83,6 +83,7 @@ config ARM
 	select HAVE_EBPF_JIT if !CPU_ENDIAN_BE32
 	select HAVE_CONTEXT_TRACKING
 	select HAVE_C_RECORDMCOUNT
+	select HAVE_BUILDTIME_MCOUNT_SORT
 	select HAVE_DEBUG_KMEMLEAK if !XIP_KERNEL
 	select HAVE_DMA_CONTIGUOUS if MMU
 	select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && !CPU_ENDIAN_BE32 && MMU
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index ebe8fc76949a..9f5bd41bf660 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -186,6 +186,7 @@ config X86
 	select HAVE_CONTEXT_TRACKING_OFFSTACK	if HAVE_CONTEXT_TRACKING
 	select HAVE_C_RECORDMCOUNT
 	select HAVE_OBJTOOL_MCOUNT		if STACK_VALIDATION
+	select HAVE_BUILDTIME_MCOUNT_SORT
 	select HAVE_DEBUG_KMEMLEAK
 	select HAVE_DMA_CONTIGUOUS
 	select HAVE_DYNAMIC_FTRACE
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index 752ed89a293b..a5eb5e7fd624 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -70,10 +70,16 @@ config HAVE_C_RECORDMCOUNT
 	help
 	  C version of recordmcount available?
 
+config HAVE_BUILDTIME_MCOUNT_SORT
+       bool
+       help
+         An architecture selects this if it sorts the mcount_loc section
+	 at build time.
+
 config BUILDTIME_MCOUNT_SORT
        bool
        default y
-       depends on BUILDTIME_TABLE_SORT && !S390
+       depends on HAVE_BUILDTIME_MCOUNT_SORT && DYNAMIC_FTRACE
        help
          Sort the mcount_loc section at build time.
 
diff --git a/scripts/Makefile b/scripts/Makefile
index ecd3acacd0ec..ce5aa9030b74 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -25,7 +25,7 @@ HOSTCFLAGS_sorttable.o += -I$(srctree)/tools/arch/x86/include
 HOSTCFLAGS_sorttable.o += -DUNWINDER_ORC_ENABLED
 endif
 
-ifdef CONFIG_DYNAMIC_FTRACE
+ifdef CONFIG_BUILDTIME_MCOUNT_SORT
 HOSTCFLAGS_sorttable.o += -DMCOUNT_SORT_ENABLED
 endif
 
-- 
2.33.0

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

* [for-linus][PATCH 02/10] tracing/histogram: Fix a potential memory leak for kstrdup()
  2022-01-28 16:18 [for-linus][PATCH 00/10] tracing: Fixes for 5.17-rc1 Steven Rostedt
  2022-01-28 16:18 ` [for-linus][PATCH 01/10] ftrace: Have architectures opt-in for mcount build time sorting Steven Rostedt
@ 2022-01-28 16:18 ` Steven Rostedt
  2022-01-28 16:18 ` [for-linus][PATCH 03/10] tracing: Avoid -Warray-bounds warning for __rel_loc macro Steven Rostedt
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Steven Rostedt @ 2022-01-28 16:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, stable, Xiaoke Wang

From: Xiaoke Wang <xkernel.wang@foxmail.com>

kfree() is missing on an error path to free the memory allocated by
kstrdup():

  p = param = kstrdup(data->params[i], GFP_KERNEL);

So it is better to free it via kfree(p).

Link: https://lkml.kernel.org/r/tencent_C52895FD37802832A3E5B272D05008866F0A@qq.com

Cc: stable@vger.kernel.org
Fixes: d380dcde9a07c ("tracing: Fix now invalid var_ref_vals assumption in trace action")
Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 kernel/trace/trace_events_hist.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 5e6a988a8a51..cd9610688ddc 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -3935,6 +3935,7 @@ static int trace_action_create(struct hist_trigger_data *hist_data,
 
 			var_ref_idx = find_var_ref_idx(hist_data, var_ref);
 			if (WARN_ON(var_ref_idx < 0)) {
+				kfree(p);
 				ret = var_ref_idx;
 				goto err;
 			}
-- 
2.33.0

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

* [for-linus][PATCH 03/10] tracing: Avoid -Warray-bounds warning for __rel_loc macro
  2022-01-28 16:18 [for-linus][PATCH 00/10] tracing: Fixes for 5.17-rc1 Steven Rostedt
  2022-01-28 16:18 ` [for-linus][PATCH 01/10] ftrace: Have architectures opt-in for mcount build time sorting Steven Rostedt
  2022-01-28 16:18 ` [for-linus][PATCH 02/10] tracing/histogram: Fix a potential memory leak for kstrdup() Steven Rostedt
@ 2022-01-28 16:18 ` Steven Rostedt
  2022-01-28 16:18 ` [for-linus][PATCH 04/10] tracing/perf: " Steven Rostedt
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Steven Rostedt @ 2022-01-28 16:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Stephen Rothwell, Kees Cook,
	Masami Hiramatsu

From: Masami Hiramatsu <mhiramat@kernel.org>

Since -Warray-bounds checks the destination size from the type of given
pointer, __assign_rel_str() macro gets warned because it passes the
pointer to the 'u32' field instead of 'trace_event_raw_*' data structure.
Pass the data address calculated from the 'trace_event_raw_*' instead of
'u32' __rel_loc field.

Link: https://lkml.kernel.org/r/20220125233154.dac280ed36944c0c2fe6f3ac@kernel.org

Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
[ This did not fix the warning, but is still a nice clean up ]
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 include/trace/trace_events.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h
index 8c6f7c433518..65d927e059d3 100644
--- a/include/trace/trace_events.h
+++ b/include/trace/trace_events.h
@@ -318,9 +318,10 @@ TRACE_MAKE_SYSTEM_STR();
 #define __get_str(field) ((char *)__get_dynamic_array(field))
 
 #undef __get_rel_dynamic_array
-#define __get_rel_dynamic_array(field)	\
-		((void *)(&__entry->__rel_loc_##field) +	\
-		 sizeof(__entry->__rel_loc_##field) +		\
+#define __get_rel_dynamic_array(field)					\
+		((void *)__entry + 					\
+		 offsetof(typeof(*__entry), __rel_loc_##field) +	\
+		 sizeof(__entry->__rel_loc_##field) +			\
 		 (__entry->__rel_loc_##field & 0xffff))
 
 #undef __get_rel_dynamic_array_len
-- 
2.33.0

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

* [for-linus][PATCH 04/10] tracing/perf: Avoid -Warray-bounds warning for __rel_loc macro
  2022-01-28 16:18 [for-linus][PATCH 00/10] tracing: Fixes for 5.17-rc1 Steven Rostedt
                   ` (2 preceding siblings ...)
  2022-01-28 16:18 ` [for-linus][PATCH 03/10] tracing: Avoid -Warray-bounds warning for __rel_loc macro Steven Rostedt
@ 2022-01-28 16:18 ` Steven Rostedt
  2022-01-28 16:18 ` [for-linus][PATCH 05/10] rtla: Make doc build optional Steven Rostedt
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Steven Rostedt @ 2022-01-28 16:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Masami Hiramatsu, Stephen Rothwell,
	Kees Cook

From: Kees Cook <keescook@chromium.org>

As done for trace_events.h, also fix the __rel_loc macro in perf.h,
which silences the -Warray-bounds warning:

In file included from ./include/linux/string.h:253,
                 from ./include/linux/bitmap.h:11,
                 from ./include/linux/cpumask.h:12,
                 from ./include/linux/mm_types_task.h:14,
                 from ./include/linux/mm_types.h:5,
                 from ./include/linux/buildid.h:5,
                 from ./include/linux/module.h:14,
                 from samples/trace_events/trace-events-sample.c:2:
In function '__fortify_strcpy',
    inlined from 'perf_trace_foo_rel_loc' at samples/trace_events/./trace-events-sample.h:519:1:
./include/linux/fortify-string.h:47:33: warning: '__builtin_strcpy' offset 12 is out of the bounds [
0, 4] [-Warray-bounds]
   47 | #define __underlying_strcpy     __builtin_strcpy
      |                                 ^
./include/linux/fortify-string.h:445:24: note: in expansion of macro '__underlying_strcpy'
  445 |                 return __underlying_strcpy(p, q);
      |                        ^~~~~~~~~~~~~~~~~~~

Also make __data struct member a proper flexible array to avoid future
problems.

Link: https://lkml.kernel.org/r/20220125220037.2738923-1-keescook@chromium.org

Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Fixes: 55de2c0b5610c ("tracing: Add '__rel_loc' using trace event macros")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 include/trace/perf.h         | 5 +++--
 include/trace/trace_events.h | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/trace/perf.h b/include/trace/perf.h
index ea4405de175a..5d48c46a3008 100644
--- a/include/trace/perf.h
+++ b/include/trace/perf.h
@@ -23,8 +23,9 @@
 
 #undef __get_rel_dynamic_array
 #define __get_rel_dynamic_array(field)	\
-		((void *)(&__entry->__rel_loc_##field) +	\
-		 sizeof(__entry->__rel_loc_##field) +		\
+		((void *)__entry +					\
+		 offsetof(typeof(*__entry), __rel_loc_##field) +	\
+		 sizeof(__entry->__rel_loc_##field) +			\
 		 (__entry->__rel_loc_##field & 0xffff))
 
 #undef __get_rel_dynamic_array_len
diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h
index 65d927e059d3..3d29919045af 100644
--- a/include/trace/trace_events.h
+++ b/include/trace/trace_events.h
@@ -128,7 +128,7 @@ TRACE_MAKE_SYSTEM_STR();
 	struct trace_event_raw_##name {					\
 		struct trace_entry	ent;				\
 		tstruct							\
-		char			__data[0];			\
+		char			__data[];			\
 	};								\
 									\
 	static struct trace_event_class event_class_##name;
-- 
2.33.0

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

* [for-linus][PATCH 05/10] rtla: Make doc build optional
  2022-01-28 16:18 [for-linus][PATCH 00/10] tracing: Fixes for 5.17-rc1 Steven Rostedt
                   ` (3 preceding siblings ...)
  2022-01-28 16:18 ` [for-linus][PATCH 04/10] tracing/perf: " Steven Rostedt
@ 2022-01-28 16:18 ` Steven Rostedt
  2022-01-28 16:18 ` [for-linus][PATCH 06/10] tools/tracing: Update Makefile to build rtla Steven Rostedt
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Steven Rostedt @ 2022-01-28 16:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Daniel Bristot de Oliveira,
	Shuah Khan

From: Shuah Khan <skhan@linuxfoundation.org>

rtla build fails due to doc build dependency on rst2man. Make
doc build optional so rtla could be built without docs. Leave
the install dependency on doc_install alone.

Link: https://lkml.kernel.org/r/20220126001301.79096-1-skhan@linuxfoundation.org

Acked-by: Daniel Bristot de Oliveira <bristot@kernel.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 tools/tracing/rtla/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/tracing/rtla/Makefile b/tools/tracing/rtla/Makefile
index 2d52ff0bff7d..7c39728d08de 100644
--- a/tools/tracing/rtla/Makefile
+++ b/tools/tracing/rtla/Makefile
@@ -59,7 +59,7 @@ endif
 .PHONY:	all
 all:	rtla
 
-rtla: $(OBJ) doc
+rtla: $(OBJ)
 	$(CC) -o rtla $(LDFLAGS) $(OBJ) $(LIBS)
 
 static: $(OBJ)
-- 
2.33.0

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

* [for-linus][PATCH 06/10] tools/tracing: Update Makefile to build rtla
  2022-01-28 16:18 [for-linus][PATCH 00/10] tracing: Fixes for 5.17-rc1 Steven Rostedt
                   ` (4 preceding siblings ...)
  2022-01-28 16:18 ` [for-linus][PATCH 05/10] rtla: Make doc build optional Steven Rostedt
@ 2022-01-28 16:18 ` Steven Rostedt
  2022-01-28 16:18 ` [for-linus][PATCH 07/10] tracing: Fix smatch warning for null glob in event_hist_trigger_parse() Steven Rostedt
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Steven Rostedt @ 2022-01-28 16:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Daniel Bristot de Oliveira,
	Shuah Khan

From: Shuah Khan <skhan@linuxfoundation.org>

Update tracing Makefile to build/install/clean rtla tragets.

Link: https://lkml.kernel.org/r/20220126002234.79337-1-skhan@linuxfoundation.org

Reviewed-by: Daniel Bristot de Oliveira <bristot@kernel.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 tools/tracing/Makefile | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/tools/tracing/Makefile b/tools/tracing/Makefile
index 87e0ec48e2e7..95e485f12d97 100644
--- a/tools/tracing/Makefile
+++ b/tools/tracing/Makefile
@@ -1,11 +1,11 @@
 # SPDX-License-Identifier: GPL-2.0
 include ../scripts/Makefile.include
 
-all: latency
+all: latency rtla
 
-clean: latency_clean
+clean: latency_clean rtla_clean
 
-install: latency_install
+install: latency_install rtla_install
 
 latency:
 	$(call descend,latency)
@@ -16,4 +16,14 @@ latency_install:
 latency_clean:
 	$(call descend,latency,clean)
 
-.PHONY: all install clean latency latency_install latency_clean
+rtla:
+	$(call descend,rtla)
+
+rtla_install:
+	$(call descend,rtla,install)
+
+rtla_clean:
+	$(call descend,rtla,clean)
+
+.PHONY: all install clean latency latency_install latency_clean \
+	rtla rtla_install rtla_clean
-- 
2.33.0

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

* [for-linus][PATCH 07/10] tracing: Fix smatch warning for null glob in event_hist_trigger_parse()
  2022-01-28 16:18 [for-linus][PATCH 00/10] tracing: Fixes for 5.17-rc1 Steven Rostedt
                   ` (5 preceding siblings ...)
  2022-01-28 16:18 ` [for-linus][PATCH 06/10] tools/tracing: Update Makefile to build rtla Steven Rostedt
@ 2022-01-28 16:18 ` Steven Rostedt
  2022-01-28 16:18 ` [for-linus][PATCH 08/10] tracing: Fix smatch warning for do while check " Steven Rostedt
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Steven Rostedt @ 2022-01-28 16:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, kernel test robot, Dan Carpenter,
	Tom Zanussi

From: Tom Zanussi <zanussi@kernel.org>

The recent rename of event_hist_trigger_parse() caused smatch
re-evaluation of trace_events_hist.c and as a result an old warning
was found:

    kernel/trace/trace_events_hist.c:6174 event_hist_trigger_parse()
    error: we previously assumed 'glob' could be null (see line 6166)

glob should never be null (and apparently smatch can also figure that
out and skip the warning when using the cross-function DB (but which
can't be used with a 0day build as it takes too much time to
generate)).

Nonetheless for clarity, remove the test but add a WARN_ON() in case
the code ever changes.

Link: https://lkml.kernel.org/r/96925e5c1f116654ada7ea0613d930b1266b5e1c.1643319703.git.zanussi@kernel.org

Fixes: f404da6e1d46c ("tracing: Add 'last error' error facility for hist triggers")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Tom Zanussi <zanussi@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 kernel/trace/trace_events_hist.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index cd9610688ddc..e0860146dd39 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -6164,7 +6164,9 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops,
 
 	lockdep_assert_held(&event_mutex);
 
-	if (glob && strlen(glob)) {
+	WARN_ON(!glob);
+
+	if (strlen(glob)) {
 		hist_err_clear();
 		last_cmd_set(file, param);
 	}
-- 
2.33.0

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

* [for-linus][PATCH 08/10] tracing: Fix smatch warning for do while check in event_hist_trigger_parse()
  2022-01-28 16:18 [for-linus][PATCH 00/10] tracing: Fixes for 5.17-rc1 Steven Rostedt
                   ` (6 preceding siblings ...)
  2022-01-28 16:18 ` [for-linus][PATCH 07/10] tracing: Fix smatch warning for null glob in event_hist_trigger_parse() Steven Rostedt
@ 2022-01-28 16:18 ` Steven Rostedt
  2022-01-28 16:18 ` [for-linus][PATCH 09/10] tracing: Propagate is_signed to expression Steven Rostedt
  2022-01-28 16:18 ` [for-linus][PATCH 10/10] tracing: Dont inc err_log entry count if entry allocation fails Steven Rostedt
  9 siblings, 0 replies; 11+ messages in thread
From: Steven Rostedt @ 2022-01-28 16:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, kernel test robot, Dan Carpenter,
	Tom Zanussi

From: Tom Zanussi <zanussi@kernel.org>

The patch ec5ce0987541: "tracing: Allow whitespace to surround hist
trigger filter" from Jan 15, 2018, leads to the following Smatch
static checker warning:

    kernel/trace/trace_events_hist.c:6199 event_hist_trigger_parse()
    warn: 'p' can't be NULL.

Since p is always checked for a NULL value at the top of loop and
nothing in the rest of the loop will set it to NULL, the warning
is correct and might as well be 1 to silence the warning.

Link: https://lkml.kernel.org/r/a1d4c79766c0cf61e20438dc35244d216633fef6.1643319703.git.zanussi@kernel.org

Fixes: ec5ce09875410 ("tracing: Allow whitespace to surround hist trigger filter")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Tom Zanussi <zanussi@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 kernel/trace/trace_events_hist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index e0860146dd39..b894d68082ea 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -6199,7 +6199,7 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops,
 			continue;
 		}
 		break;
-	} while (p);
+	} while (1);
 
 	if (!p)
 		param = NULL;
-- 
2.33.0

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

* [for-linus][PATCH 09/10] tracing: Propagate is_signed to expression
  2022-01-28 16:18 [for-linus][PATCH 00/10] tracing: Fixes for 5.17-rc1 Steven Rostedt
                   ` (7 preceding siblings ...)
  2022-01-28 16:18 ` [for-linus][PATCH 08/10] tracing: Fix smatch warning for do while check " Steven Rostedt
@ 2022-01-28 16:18 ` Steven Rostedt
  2022-01-28 16:18 ` [for-linus][PATCH 10/10] tracing: Dont inc err_log entry count if entry allocation fails Steven Rostedt
  9 siblings, 0 replies; 11+ messages in thread
From: Steven Rostedt @ 2022-01-28 16:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, stable, Yordan Karadzhov, Tom Zanussi

From: Tom Zanussi <zanussi@kernel.org>

During expression parsing, a new expression field is created which
should inherit the properties of the operands, such as size and
is_signed.

is_signed propagation was missing, causing spurious errors with signed
operands.  Add it in parse_expr() and parse_unary() to fix the problem.

Link: https://lkml.kernel.org/r/f4dac08742fd7a0920bf80a73c6c44042f5eaa40.1643319703.git.zanussi@kernel.org

Cc: stable@vger.kernel.org
Fixes: 100719dcef447 ("tracing: Add simple expression support to hist triggers")
Reported-by: Yordan Karadzhov <ykaradzhov@vmware.com>
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=215513
Signed-off-by: Tom Zanussi <zanussi@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 kernel/trace/trace_events_hist.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index b894d68082ea..ada87bfb5bb8 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -2503,6 +2503,8 @@ static struct hist_field *parse_unary(struct hist_trigger_data *hist_data,
 		(HIST_FIELD_FL_TIMESTAMP | HIST_FIELD_FL_TIMESTAMP_USECS);
 	expr->fn = hist_field_unary_minus;
 	expr->operands[0] = operand1;
+	expr->size = operand1->size;
+	expr->is_signed = operand1->is_signed;
 	expr->operator = FIELD_OP_UNARY_MINUS;
 	expr->name = expr_str(expr, 0);
 	expr->type = kstrdup_const(operand1->type, GFP_KERNEL);
@@ -2719,6 +2721,7 @@ static struct hist_field *parse_expr(struct hist_trigger_data *hist_data,
 
 		/* The operand sizes should be the same, so just pick one */
 		expr->size = operand1->size;
+		expr->is_signed = operand1->is_signed;
 
 		expr->operator = field_op;
 		expr->type = kstrdup_const(operand1->type, GFP_KERNEL);
-- 
2.33.0

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

* [for-linus][PATCH 10/10] tracing: Dont inc err_log entry count if entry allocation fails
  2022-01-28 16:18 [for-linus][PATCH 00/10] tracing: Fixes for 5.17-rc1 Steven Rostedt
                   ` (8 preceding siblings ...)
  2022-01-28 16:18 ` [for-linus][PATCH 09/10] tracing: Propagate is_signed to expression Steven Rostedt
@ 2022-01-28 16:18 ` Steven Rostedt
  9 siblings, 0 replies; 11+ messages in thread
From: Steven Rostedt @ 2022-01-28 16:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, stable, Tom Zanussi

From: Tom Zanussi <zanussi@kernel.org>

tr->n_err_log_entries should only be increased if entry allocation
succeeds.

Doing it when it fails won't cause any problems other than wasting an
entry, but should be fixed anyway.

Link: https://lkml.kernel.org/r/cad1ab28f75968db0f466925e7cba5970cec6c29.1643319703.git.zanussi@kernel.org

Cc: stable@vger.kernel.org
Fixes: 2f754e771b1a6 ("tracing: Don't inc err_log entry count if entry allocation fails")
Signed-off-by: Tom Zanussi <zanussi@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 kernel/trace/trace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index a569a0cb81ee..c860f582b078 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -7740,7 +7740,8 @@ static struct tracing_log_err *get_tracing_log_err(struct trace_array *tr)
 		err = kzalloc(sizeof(*err), GFP_KERNEL);
 		if (!err)
 			err = ERR_PTR(-ENOMEM);
-		tr->n_err_log_entries++;
+		else
+			tr->n_err_log_entries++;
 
 		return err;
 	}
-- 
2.33.0

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

end of thread, other threads:[~2022-01-28 16:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-28 16:18 [for-linus][PATCH 00/10] tracing: Fixes for 5.17-rc1 Steven Rostedt
2022-01-28 16:18 ` [for-linus][PATCH 01/10] ftrace: Have architectures opt-in for mcount build time sorting Steven Rostedt
2022-01-28 16:18 ` [for-linus][PATCH 02/10] tracing/histogram: Fix a potential memory leak for kstrdup() Steven Rostedt
2022-01-28 16:18 ` [for-linus][PATCH 03/10] tracing: Avoid -Warray-bounds warning for __rel_loc macro Steven Rostedt
2022-01-28 16:18 ` [for-linus][PATCH 04/10] tracing/perf: " Steven Rostedt
2022-01-28 16:18 ` [for-linus][PATCH 05/10] rtla: Make doc build optional Steven Rostedt
2022-01-28 16:18 ` [for-linus][PATCH 06/10] tools/tracing: Update Makefile to build rtla Steven Rostedt
2022-01-28 16:18 ` [for-linus][PATCH 07/10] tracing: Fix smatch warning for null glob in event_hist_trigger_parse() Steven Rostedt
2022-01-28 16:18 ` [for-linus][PATCH 08/10] tracing: Fix smatch warning for do while check " Steven Rostedt
2022-01-28 16:18 ` [for-linus][PATCH 09/10] tracing: Propagate is_signed to expression Steven Rostedt
2022-01-28 16:18 ` [for-linus][PATCH 10/10] tracing: Dont inc err_log entry count if entry allocation fails 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).