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>] [day] [month] [year] [list]
Date:	Fri, 27 Mar 2009 10:23:32 +0100
From:	Markus Metzger <markus.t.metzger@...el.com>
To:	linux-kernel@...r.kernel.org, mingo@...e.hu, tglx@...utronix.de,
	hpa@...or.com
Cc:	markus.t.metzger@...el.com, markus.t.metzger@...il.com,
	roland@...hat.com, eranian@...glemail.com, oleg@...hat.com,
	juan.villacis@...el.com, ak@...ux.jf.intel.com
Subject: [patch 11/14] x86, ptrace: remove ptrace_fork, use init_task instead

I introduced ptrace_fork to initialize bts tracing for a new task.

Now I've seen that there is already a ptrace_init_task() called from
tracehook that does essentially the same thing.

Remove ptrace_fork and add an arch_ variant to ptrace_init_task.


Signed-off-by: Markus Metzger <markus.t.metzger@...el.com>
---

Index: git-tip/arch/x86/include/asm/ptrace.h
===================================================================
--- git-tip.orig/arch/x86/include/asm/ptrace.h	2009-03-27 08:18:46.000000000 +0100
+++ git-tip/arch/x86/include/asm/ptrace.h	2009-03-27 08:29:32.000000000 +0100
@@ -236,13 +236,12 @@ extern int do_set_thread_area(struct tas
 			      struct user_desc __user *info, int can_allocate);
 
 extern void x86_ptrace_untrace(struct task_struct *child);
-extern void x86_ptrace_fork(struct task_struct *child,
-			    unsigned long clone_flags);
+extern void x86_ptrace_init_task(struct task_struct *child);
 extern void x86_ptrace_report_exit(long exit_code);
 
-#define arch_ptrace_untrace(tsk) x86_ptrace_untrace(tsk)
-#define arch_ptrace_fork(child, flags) x86_ptrace_fork(child, flags)
-#define arch_ptrace_report_exit(code) x86_ptrace_report_exit(code)
+#define arch_ptrace_untrace(tsk)	x86_ptrace_untrace(tsk)
+#define arch_ptrace_init_task(child)	x86_ptrace_init_task(child)
+#define arch_ptrace_report_exit(code)	x86_ptrace_report_exit(code)
 
 #endif /* __KERNEL__ */
 
Index: git-tip/include/linux/ptrace.h
===================================================================
--- git-tip.orig/include/linux/ptrace.h	2009-03-27 08:18:46.000000000 +0100
+++ git-tip/include/linux/ptrace.h	2009-03-27 08:29:32.000000000 +0100
@@ -154,6 +154,18 @@ static inline int ptrace_event(int mask,
 	return 1;
 }
 
+#ifndef arch_ptrace_init_task
+/**
+ * arch_ptrace_init_task - initialize machine specific state for a new child
+ * @child:		new child task
+ *
+ * This is called immediately after initializing the general ptrace state.
+ *
+ * Called with current's siglock and write_lock_irq(&tasklist_lock) held.
+ */
+#define arch_ptrace_init_task(child)	do { } while (0)
+#endif
+
 /**
  * ptrace_init_task - initialize ptrace state for a new child
  * @child:		new child task
@@ -174,6 +186,8 @@ static inline void ptrace_init_task(stru
 		child->ptrace = current->ptrace;
 		ptrace_link(child, current->parent);
 	}
+
+	arch_ptrace_init_task(child);
 }
 
 /**
@@ -326,15 +340,6 @@ static inline void user_enable_block_ste
 #define arch_ptrace_untrace(task)		do { } while (0)
 #endif
 
-#ifndef arch_ptrace_fork
-/*
- * Do machine-specific work to initialize a new task.
- *
- * This is called from copy_process().
- */
-#define arch_ptrace_fork(child, clone_flags)	do { } while (0)
-#endif
-
 #ifndef arch_ptrace_report_exit
 /**
  * arch_ptrace_report_exit - Do machine specific work for exiting ptraced tasks
Index: git-tip/kernel/fork.c
===================================================================
--- git-tip.orig/kernel/fork.c	2009-03-27 08:18:46.000000000 +0100
+++ git-tip/kernel/fork.c	2009-03-27 08:29:32.000000000 +0100
@@ -1100,8 +1100,6 @@ static struct task_struct *copy_process(
 #ifdef CONFIG_DEBUG_MUTEXES
 	p->blocked_on = NULL; /* not blocked yet */
 #endif
-	if (unlikely(current->ptrace))
-		ptrace_fork(p, clone_flags);
 
 	/* Perform scheduler related setup. Assign this task to a CPU. */
 	sched_fork(p, clone_flags);
Index: git-tip/kernel/ptrace.c
===================================================================
--- git-tip.orig/kernel/ptrace.c	2009-03-27 08:18:46.000000000 +0100
+++ git-tip/kernel/ptrace.c	2009-03-27 08:29:32.000000000 +0100
@@ -27,16 +27,6 @@
 
 
 /*
- * Initialize a new task whose father had been ptraced.
- *
- * Called from copy_process().
- */
-void ptrace_fork(struct task_struct *child, unsigned long clone_flags)
-{
-	arch_ptrace_fork(child, clone_flags);
-}
-
-/*
  * ptrace a task: make the debugger its new parent and
  * move it to the ptrace list.
  *
Index: git-tip/arch/x86/kernel/ptrace.c
===================================================================
--- git-tip.orig/arch/x86/kernel/ptrace.c	2009-03-27 08:29:32.000000000 +0100
+++ git-tip/arch/x86/kernel/ptrace.c	2009-03-27 08:29:32.000000000 +0100
@@ -781,7 +781,7 @@ static int ptrace_bts_size(struct task_s
 	return (trace->ds.top - trace->ds.begin) / trace->ds.size;
 }
 
-static void ptrace_bts_fork(struct task_struct *tsk)
+static void ptrace_bts_init_task(struct task_struct *tsk)
 {
 	tsk->bts = NULL;
 	tsk->bts_buffer = NULL;
@@ -926,15 +926,14 @@ static void ptrace_bts_untrace(struct ta
 	WARN(child->bts, "leaking BTS tracer\n");
 }
 #else
-static inline void ptrace_bts_fork(struct task_struct *tsk) {}
+static inline void ptrace_bts_init_task(struct task_struct *tsk) {}
 static inline void ptrace_bts_untrace(struct task_struct *child) {}
 static inline void ptrace_bts_exit(void) {}
 #endif /* CONFIG_X86_PTRACE_BTS */
 
-void x86_ptrace_fork(struct task_struct *child,
-		     unsigned long clone_flags)
+void x86_ptrace_init_task(struct task_struct *child)
 {
-	ptrace_bts_fork(child);
+	ptrace_bts_init_task(child);
 }
 
 void x86_ptrace_untrace(struct task_struct *child)
---------------------------------------------------------------------
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen Germany
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Douglas Lusk, Peter Gleissner, Hannes Schwaderer
Registergericht: Muenchen HRB 47456 Ust.-IdNr.
VAT Registration No.: DE129385895
Citibank Frankfurt (BLZ 502 109 00) 600119052

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ