All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] c/r: prctl: Add ability to get clear_tid_address
@ 2012-03-05  8:11 Cyrill Gorcunov
  2012-03-07 14:56 ` Cyrill Gorcunov
  0 siblings, 1 reply; 2+ messages in thread
From: Cyrill Gorcunov @ 2012-03-05  8:11 UTC (permalink / raw)
  To: LKML
  Cc: Andrew Vagin, Pedro Alves, Oleg Nesterov, Pavel Emelyanov,
	Tejun Heo, Andrew Morton

Hi guys,

there were a converation about ability to retrieve task::clear_tid_address
(https://lkml.org/lkml/2012/2/3/116) via ptrace call, which was found as being
a bit inappropriate. So we've switched to prctl interface instead. What do
you think? Did I miss something? Comments are welcome

	Cyrill
---
Subject: [RFC] c/r: prctl: Add ability to get clear_tid_address

From: Andrew Vagin <avagin@openvz.org>

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

We already have sys_set_tid_address() to change this
address for current task but there is no way to obtain
it from a user space.

Without ability to find this address and dump it we can't
restore pthread'ed apps which do call pthread_join() once
they have been restored.

This patch introduces PR_GET_TID_ADDRESS prctl option
which allow current process to obtain own clear_tid_address.

This feature is available iif CONFIG_CHECKPOINT_RESTORE is set.

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
CC: Pedro Alves <palves@redhat.com>
CC: Oleg Nesterov <oleg@redhat.com>
CC: Pavel Emelyanov <xemul@parallels.com>
CC: Tejun Heo <tj@kernel.org>
---
 include/linux/prctl.h |    2 ++
 kernel/sys.c          |   13 +++++++++++++
 2 files changed, 15 insertions(+)

Index: linux-2.6.git/include/linux/prctl.h
===================================================================
--- linux-2.6.git.orig/include/linux/prctl.h
+++ linux-2.6.git/include/linux/prctl.h
@@ -120,4 +120,6 @@
 # define PR_SET_MM_AUXV			12
 # define PR_SET_MM_EXE_FILE		13
 
+#define PR_GET_TID_ADDRESS		36
+
 #endif /* _LINUX_PRCTL_H */
Index: linux-2.6.git/kernel/sys.c
===================================================================
--- linux-2.6.git.orig/kernel/sys.c
+++ linux-2.6.git/kernel/sys.c
@@ -1903,12 +1903,22 @@ out:
 	up_read(&mm->mmap_sem);
 	return error;
 }
+
+static int prctl_get_tid_address(struct task_struct *me, int __user **tid_addr)
+{
+	return put_user(me->clear_child_tid, addr);
+}
+
 #else /* CONFIG_CHECKPOINT_RESTORE */
 static int prctl_set_mm(int opt, unsigned long addr,
 			unsigned long arg4, unsigned long arg5)
 {
 	return -EINVAL;
 }
+static int prctl_get_tid_address(struct task_struct *me, int __user **tid_addr)
+{
+	return -EINVAL;
+}
 #endif
 
 SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
@@ -2063,6 +2073,9 @@ SYSCALL_DEFINE5(prctl, int, option, unsi
 		case PR_SET_MM:
 			error = prctl_set_mm(arg2, arg3, arg4, arg5);
 			break;
+		case PR_GET_TID_ADDRESS:
+			error = prctl_get_tid_address(me, (int __user **)arg2);
+			break;
 		default:
 			error = -EINVAL;
 			break;

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

* Re: [RFC] c/r: prctl: Add ability to get clear_tid_address
  2012-03-05  8:11 [RFC] c/r: prctl: Add ability to get clear_tid_address Cyrill Gorcunov
@ 2012-03-07 14:56 ` Cyrill Gorcunov
  0 siblings, 0 replies; 2+ messages in thread
From: Cyrill Gorcunov @ 2012-03-07 14:56 UTC (permalink / raw)
  To: LKML
  Cc: Andrew Vagin, Pedro Alves, Oleg Nesterov, Pavel Emelyanov,
	Tejun Heo, Andrew Morton

On Mon, Mar 5, 2012 at 12:11 PM, Cyrill Gorcunov <gorcunov@openvz.org> wrote:
> Hi guys,
>
> there were a converation about ability to retrieve task::clear_tid_address
> (https://lkml.org/lkml/2012/2/3/116) via ptrace call, which was found as being
> a bit inappropriate. So we've switched to prctl interface instead. What do
> you think? Did I miss something? Comments are welcome
>

This patch has a typo, so ignore it please. I'll resend it in another series.

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

end of thread, other threads:[~2012-03-07 14:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-05  8:11 [RFC] c/r: prctl: Add ability to get clear_tid_address Cyrill Gorcunov
2012-03-07 14:56 ` Cyrill Gorcunov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.