Skip to contentSkip to conversation

tracing: A few more updates to 6.3

PATCH New Steven Rostedt 1 participant 3 messages Apr 6, 2023

Subsystems (3)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

cover tracing: A few more updates to 6.3

Some more tracing fixes for 6.3:

- Reset direct->addr back to its original value on error in updating the direct trampoline code.

- Make lastcmd_mutex static.

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

Head SHA1: 31c683967174b487939efaf65e41f5ff1404e141

Steven Rostedt (Google) (1):
tracing/synthetic: Make lastcmd_mutex static

Zheng Yejian (1):

      ftrace: Fix issue that 'direct->addr' not restored in modify_ftrace_direct()

----

 kernel/trace/ftrace.c             | 15 +++++++++------
 kernel/trace/trace_events_synth.c |  2 +-
 2 files changed, 10 insertions(+), 7 deletions(-)
author maintainer
#1 lore raw

PATCH 1/2 ftrace: Fix issue that direct->addr not restored in modify_ftrace_direct()

From: Zheng Yejian <[email protected]>

Syzkaller report a WARNING: "WARN_ON(!direct)" in modify_ftrace_direct().

Root cause is 'direct->addr' was changed from 'old_addr' to 'new_addr' but not restored if error happened on calling ftrace_modify_direct_caller(). Then it can no longer find 'direct' by that 'old_addr'.

To fix it, restore 'direct->addr' to 'old_addr' explicitly in error path.

---
 kernel/trace/ftrace.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
kernel/trace/ftrace.c +9 -6
index 0feea145bb29..c67bcc89a771 100644
@@ -5667,12 +5667,15 @@ int modify_ftrace_direct(unsigned long ip,
 		ret = 0;
 	}
 
-	if (unlikely(ret && new_direct)) {
-		direct->count++;
-		list_del_rcu(&new_direct->next);
-		synchronize_rcu_tasks();
-		kfree(new_direct);
-		ftrace_direct_func_count--;
+	if (ret) {
+		direct->addr = old_addr;
+		if (unlikely(new_direct)) {
+			direct->count++;
+			list_del_rcu(&new_direct->next);
+			synchronize_rcu_tasks();
+			kfree(new_direct);
+			ftrace_direct_func_count--;
+		}
 	}
 
  out_unlock:
Signature · 1 line
2.39.2
author maintainer
#2 lore raw

PATCH 2/2 tracing/synthetic: Make lastcmd_mutex static

In reply to Steven Rostedt

From: "Steven Rostedt (Google)" <[email protected]>

The lastcmd_mutex is only used in trace_events_synth.c and should be static.

Cc Masami Hiramatsu <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Tze-nan Wu <[email protected]>
Fixes 4ccf11c4e8a8e ("tracing/synthetic: Fix races on freeing last_cmd")
---
 kernel/trace/trace_events_synth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_synth.c +1 -1
index f0ff730125bf..d6a70aff2410 100644
@@ -44,7 +44,7 @@ enum { ERRORS };
 
 static const char *err_text[] = { ERRORS };
 
-DEFINE_MUTEX(lastcmd_mutex);
+static DEFINE_MUTEX(lastcmd_mutex);
 static char *last_cmd;
 
 static int errpos(const char *str)
Signature · 1 line
2.39.2