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: <20171214202044.1629279-3-qinteng@fb.com>
Date:   Thu, 14 Dec 2017 12:20:43 -0800
From:   Teng Qin <qinteng@...com>
To:     <peterz@...radead.org>
CC:     <mingo@...hat.com>, <ast@...com>, <bgregg@...flix.com>,
        <daniel@...earbox.net>, <yhs@...com>,
        <linux-kernel@...r.kernel.org>, <Kernel-team@...com>,
        Teng Qin <qinteng@...com>
Subject: [PATCH tip 2/3] Improve sched_process_fork Tracepoint

This commit adds value of the clone_flag to sched_process_fork's
Tracepoint struct. The value is passed as an argument of the Tracepoint.
It is useful when debugging Processes created via different clone flags.

This commit also exposes pointers of the parent and child task_struct in
the Tracepoint's struct. BPF programs can read task information via task
struct pointer. Exposing these pointers explicitly gives BPF programs an
easy and reliable way of using the Tracepoint.

Signed-off-by: Teng Qin <qinteng@...com>
---
 include/trace/events/sched.h | 11 +++++++++--
 kernel/fork.c                |  2 +-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index 9297b33..e8bb6b0 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -278,15 +278,19 @@ TRACE_EVENT(sched_process_wait,
  */
 TRACE_EVENT(sched_process_fork,
 
-	TP_PROTO(struct task_struct *parent, struct task_struct *child),
+	TP_PROTO(struct task_struct *parent, struct task_struct *child,
+		 unsigned long clone_flags),
 
-	TP_ARGS(parent, child),
+	TP_ARGS(parent, child, clone_flags),
 
 	TP_STRUCT__entry(
 		__array(	char,	parent_comm,	TASK_COMM_LEN	)
 		__field(	pid_t,	parent_pid			)
 		__array(	char,	child_comm,	TASK_COMM_LEN	)
 		__field(	pid_t,	child_pid			)
+		__field(	unsigned long,	clone_flags		)
+		__field(	void *,	parent_task			)
+		__field(	void *,	child_task			)
 	),
 
 	TP_fast_assign(
@@ -294,6 +298,9 @@ TRACE_EVENT(sched_process_fork,
 		__entry->parent_pid	= parent->pid;
 		memcpy(__entry->child_comm, child->comm, TASK_COMM_LEN);
 		__entry->child_pid	= child->pid;
+		__entry->clone_flags	= clone_flags;
+		__entry->parent_task	= (void *)parent;
+		__entry->child_task	= (void *)child;
 	),
 
 	TP_printk("comm=%s pid=%d child_comm=%s child_pid=%d",
diff --git a/kernel/fork.c b/kernel/fork.c
index 432eadf..777985e 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -2053,7 +2053,7 @@ long _do_fork(unsigned long clone_flags,
 		struct completion vfork;
 		struct pid *pid;
 
-		trace_sched_process_fork(current, p);
+		trace_sched_process_fork(current, p, clone_flags);
 
 		pid = get_task_pid(p, PIDTYPE_PID);
 		nr = pid_vnr(pid);
-- 
2.9.5

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ