From: Andrew Vagin <avagin@openvz.org>
To: linux-kernel@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org,
Alexander Viro <viro@zeniv.linux.org.uk>,
Roland McGrath <roland@redhat.com>,
Oleg Nesterov <oleg@redhat.com>,
Steven Rostedt <rostedt@goodmis.org>,
Cyrill Gorcunov <gorcunov@openvz.org>,
Pavel Emelyanov <xemul@parallels.com>, Tejun Heo <tj@kernel.org>
Subject: [PATCH 2/2] ptrace: add ability to attach a file descriptor to another task
Date: Fri, 16 Dec 2011 13:46:23 +0300 [thread overview]
Message-ID: <1324032383-791758-3-git-send-email-avagin@openvz.org> (raw)
In-Reply-To: <1324032383-791758-1-git-send-email-avagin@openvz.org>
Signed-off-by: Andrew Vagin <avagin@openvz.org>
---
include/linux/ptrace.h | 1 +
kernel/ptrace.c | 27 +++++++++++++++++++++++++++
2 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
index 800f113..8439ce9 100644
--- a/include/linux/ptrace.h
+++ b/include/linux/ptrace.h
@@ -50,6 +50,7 @@
#define PTRACE_SEIZE 0x4206
#define PTRACE_INTERRUPT 0x4207
#define PTRACE_LISTEN 0x4208
+#define PTRACE_DUPFD 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 24d0447..a646d01 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -24,6 +24,7 @@
#include <linux/regset.h>
#include <linux/hw_breakpoint.h>
#include <linux/cn_proc.h>
+#include <linux/file.h>
static int ptrace_trapping_sleep_fn(void *flags)
@@ -826,6 +827,32 @@ int ptrace_request(struct task_struct *child, long request,
break;
}
#endif
+ case PTRACE_DUPFD:
+ {
+ struct file *file = fget_raw(data);
+ ret = -EBADF;
+
+ if (!file)
+ break;
+
+ task_lock(child);
+ if (!child->files)
+ goto out_getfd;
+
+ ret = alloc_task_fd(child, 0, 0);
+ if (ret < 0) {
+ fput(file);
+ goto out_getfd;
+ }
+
+ fd_task_install(child, ret, file);
+
+out_getfd:
+ task_unlock(child);
+
+ break;
+ }
+
default:
break;
}
--
1.7.1
next prev parent reply other threads:[~2011-12-16 10:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-16 10:46 [PATCH 0/2] ptrace: add ability to attach a file descriptor to another process Andrew Vagin
2011-12-16 10:46 ` [PATCH 1/2] fs: add ability to attach and to allocate fd for non current tasks Andrew Vagin
2011-12-16 10:46 ` Andrew Vagin [this message]
2011-12-18 18:17 ` [PATCH 2/2] ptrace: add ability to attach a file descriptor to another task Oleg Nesterov
2011-12-16 16:05 ` [PATCH 0/2] ptrace: add ability to attach a file descriptor to another process Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1324032383-791758-3-git-send-email-avagin@openvz.org \
--to=avagin@openvz.org \
--cc=gorcunov@openvz.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=roland@redhat.com \
--cc=rostedt@goodmis.org \
--cc=tj@kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=xemul@parallels.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®