From 260ea1013283d8acbb451459ed1ca560c1445c20 Mon Sep 17 00:00:00 2001 From: "Eric W. Biederman" Date: Fri, 23 Jun 2006 02:05:18 -0700 Subject: [PATCH] ptrace: document the locking rules After a lot of reading the code and thinking about how it behaves I have managed to figure out what the current ptrace locking rules are. The current code is in much better that it appears at first glance. The troublesome code paths are actually the code paths that violate the current rules. ptrace uses simple exclusive access as it's locking. You can only touch task->ptrace if the task is stopped and you are the ptracer, or if the task is running and are the task itself. Very simple, very easy to maintain. It just needs to be documented so people know not to touch ptrace from elsewhere. Currently we do have a few pieces of code that are in violation of this rule. Particularly the core dump code, and ptrace_attach. But so far the code looks fixable. Signed-off-by: Eric W. Biederman Cc: Oleg Nesterov Cc: Roland McGrath Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/ptrace.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/linux/ptrace.h') diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h index 0d36750fc0f1..ee918bc6e18c 100644 --- a/include/linux/ptrace.h +++ b/include/linux/ptrace.h @@ -51,6 +51,10 @@ #ifdef __KERNEL__ /* * Ptrace flags + * + * The owner ship rules for task->ptrace which holds the ptrace + * flags is simple. When a task is running it owns it's task->ptrace + * flags. When the a task is stopped the ptracer owns task->ptrace. */ #define PT_PTRACED 0x00000001 -- cgit v1.2.2