public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ptrace: add ability to get clear_tid_address
@ 2012-02-03 11:11 Andrew Vagin
  2012-02-03 16:25 ` Tejun Heo
  0 siblings, 1 reply; 22+ messages in thread
From: Andrew Vagin @ 2012-02-03 11:11 UTC (permalink / raw)
  To: linux-kernel
  Cc: Oleg Nesterov, Roland McGrath, Cyrill Gorcunov, Pavel Emelyanov,
	Tejun Heo, avagin

Zero is written at clear_tid_address, when the process exits.
This functionality is used by pthread_join().

sys_set_tid_address() changes this address for current task.

Before this patch clear_tid_address could not be got from user space.
I want to dump a full state of a task, so I need this address.
Also I think it may be useful for debugging a multithreading program.

I am not sure that ptrace is suitable place. It may be added in prctl,
but I think it's a bit useless and strange. I can't image a real
situation (avoid checkpointing) when a thread will want to get own
clear_tid_address from itself, this address is used by parent ussually.

Signed-off-by: Andrew Vagin <avagin@openvz.org>
---
 include/linux/ptrace.h |    3 +++
 kernel/ptrace.c        |    3 +++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
index c2f1f6a..79b84a3 100644
--- a/include/linux/ptrace.h
+++ b/include/linux/ptrace.h
@@ -51,6 +51,9 @@
 #define PTRACE_INTERRUPT	0x4207
 #define PTRACE_LISTEN		0x4208
 
+/* Get clear_child_tid address */
+#define PTRACE_GET_TID_ADDRESS	0x4209
+
 /* flags in @data for PTRACE_SEIZE */
 #define PTRACE_SEIZE_DEVEL	0x80000000 /* temp flag for development */
 
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 00ab2ca..ed7fbe7 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -845,6 +845,9 @@ int ptrace_request(struct task_struct *child, long request,
 		break;
 	}
 #endif
+	case PTRACE_GET_TID_ADDRESS:
+		return put_user(child->clear_child_tid, (int __user **) data);
+
 	default:
 		break;
 	}
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2012-02-10  3:03 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-03 11:11 [PATCH] ptrace: add ability to get clear_tid_address Andrew Vagin
2012-02-03 16:25 ` Tejun Heo
2012-02-03 16:30   ` Cyrill Gorcunov
2012-02-03 16:41     ` Oleg Nesterov
2012-02-03 16:54       ` Cyrill Gorcunov
2012-02-03 16:45   ` Pavel Emelyanov
2012-02-03 16:51     ` Oleg Nesterov
2012-02-07 20:07       ` Pedro Alves
2012-02-07 20:56         ` Cyrill Gorcunov
2012-02-07 21:15           ` Pedro Alves
2012-02-07 21:51             ` Cyrill Gorcunov
2012-02-08 12:30               ` Pedro Alves
2012-02-08 12:42                 ` Cyrill Gorcunov
2012-02-08 17:31                 ` Oleg Nesterov
2012-02-08 18:04                   ` Pedro Alves
2012-02-08 19:02                     ` Oleg Nesterov
2012-02-08 19:20                       ` Cyrill Gorcunov
2012-02-08 19:21                       ` Jan Kratochvil
2012-02-08 19:42                       ` Pedro Alves
2012-02-08 13:41         ` Andrew Vagin
2012-02-08 18:12           ` Jan Kratochvil
2012-02-10  3:02             ` Jamie Lokier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox