The patch titled ptrace: document the locking rules has been added to the -mm tree. Its filename is ptrace-document-the-locking-rules.patch See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this From: ebiederm@xxxxxxxxxxxx (Eric W. Biederman) 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 <ebiederm@xxxxxxxxxxxx> Cc: Oleg Nesterov <oleg@xxxxxxxxxx> Cc: Roland McGrath <roland@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- include/linux/ptrace.h | 4 ++++ include/linux/sched.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff -puN include/linux/ptrace.h~ptrace-document-the-locking-rules include/linux/ptrace.h --- devel/include/linux/ptrace.h~ptrace-document-the-locking-rules 2006-04-16 17:44:56.000000000 -0700 +++ devel-akpm/include/linux/ptrace.h 2006-04-16 17:44:56.000000000 -0700 @@ -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 diff -puN include/linux/sched.h~ptrace-document-the-locking-rules include/linux/sched.h --- devel/include/linux/sched.h~ptrace-document-the-locking-rules 2006-04-16 17:44:56.000000000 -0700 +++ devel-akpm/include/linux/sched.h 2006-04-16 17:44:56.000000000 -0700 @@ -1274,7 +1274,7 @@ static inline int thread_group_empty(tas (thread_group_leader(p) && !thread_group_empty(p)) /* - * Protects ->fs, ->files, ->mm, ->ptrace, ->group_info, ->comm, keyring + * Protects ->fs, ->files, ->mm, ->group_info, ->comm, keyring * subscriptions and synchronises with wait4(). Also used in procfs. Also * pins the final release of task.io_context. Also protects ->cpuset. * _ Patches currently in -mm which might be from ebiederm@xxxxxxxxxxxx are origin.patch task-make-task-list-manipulations-rcu-safe.patch avoid-tasklist_lock-at-getrusage-for-multithreaded-case-too.patch ptrace-document-the-locking-rules.patch proc-fix-the-inode-number-on-proc-pid-fd.patch proc-remove-useless-bkl-in-proc_pid_readlink.patch proc-remove-unnecessary-and-misleading-assignments.patch proc-simplify-the-ownership-rules-for-proc.patch proc-replace-proc_inodetype-with-proc_inodefd.patch proc-remove-bogus-proc_task_permission.patch proc-kill-proc_mem_inode_operations.patch proc-properly-filter-out-files-that-are-not-visible.patch proc-fix-the-link-count-for-proc-pid-task.patch proc-move-proc_maps_operations-into-task_mmuc.patch proc-rewrite-the-proc-dentry-flush-on-exit.patch proc-close-the-race-of-a-process-dying-durning.patch proc-refactor-reading-directories-of-tasks.patch proc-remove-tasklist_lock-from-proc_pid_readdir.patch proc-remove-tasklist_lock-from-proc_pid_lookup-and.patch proc-remove-tasklist_lock-from-proc_pid_readdir-simply-fix-first_tgid.patch proc-make-proc_numbuf-the-buffer-size-for-holding-a.patch proc-dont-lock-task_structs-indefinitely.patch proc-use-struct-pid-not-struct-task_ref.patch proc-optimize-proc_check_dentry_visible.patch proc-use-sane-permission-checks-on-the-proc-pid-fd.patch proc-cleanup-proc_fd_access_allowed.patch proc-remove-tasklist_lock-from-proc_task_readdir.patch simplify-fix-first_tid.patch cleanup-next_tid.patch coredump-optimize-mm-users-traversal.patch coredump-speedup-sigkill-sending.patch coredump-kill-ptrace-related-stuff.patch coredump-dont-take-tasklist_lock.patch pidhash-temporary-debug-checks.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html