lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220329163931.710555-4-xiehuan09@gmail.com>
Date:   Wed, 30 Mar 2022 00:39:31 +0800
From:   Jeff Xie <xiehuan09@...il.com>
To:     rostedt@...dmis.org
Cc:     mingo@...hat.com, mhiramat@...nel.org, zanussi@...nel.org,
        linux-kernel@...r.kernel.org, Jeff Xie <xiehuan09@...il.com>
Subject: [PATCH 3/3] tracing: make tp_printk work on syscall tracepoints

Adding printk for syscall tracepoints for the tp_printk work.

Signed-off-by: Jeff Xie <xiehuan09@...il.com>
---
 kernel/trace/trace_syscalls.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index f755bde42fd0..9798122166d3 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -290,6 +290,25 @@ static int __init syscall_enter_define_fields(struct trace_event_call *call)
 	return ret;
 }
 
+static void syscall_output_printk(struct trace_entry *ent,
+		struct trace_event_file *trace_file, struct trace_array *tr)
+{
+	unsigned long flags;
+	struct trace_iterator *iter = tracepoint_print_iter;
+	struct trace_event *event = &trace_file->event_call->event;
+
+	spin_lock_irqsave(&tracepoint_iter_lock, flags);
+
+	trace_seq_init(&iter->seq);
+	iter->ent = ent;
+	iter->tr = tr;
+	event->funcs->trace(iter, 0, event);
+	trace_seq_putc(&iter->seq, 0);
+	pr_info("%s", iter->seq.buffer);
+
+	spin_unlock_irqrestore(&tracepoint_iter_lock, flags);
+}
+
 static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id)
 {
 	struct trace_array *tr = data;
@@ -333,6 +352,9 @@ static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id)
 	syscall_get_arguments(current, regs, args);
 	memcpy(entry->args, args, sizeof(unsigned long) * sys_data->nb_args);
 
+	if (static_key_false(&tracepoint_printk_key.key))
+		syscall_output_printk(&entry->ent, trace_file, tr);
+
 	event_trigger_unlock_commit(trace_file, buffer, event, entry,
 				    trace_ctx);
 }
@@ -376,6 +398,9 @@ static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret)
 	entry->nr = syscall_nr;
 	entry->ret = syscall_get_return_value(current, regs);
 
+	if (static_key_false(&tracepoint_printk_key.key))
+		syscall_output_printk(&entry->ent, trace_file, tr);
+
 	event_trigger_unlock_commit(trace_file, buffer, event, entry,
 				    trace_ctx);
 }
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ