[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1324032383-791758-3-git-send-email-avagin@openvz.org>
Date: Fri, 16 Dec 2011 13:46:23 +0300
From: Andrew Vagin <avagin@...nvz.org>
To: linux-kernel@...r.kernel.org
Cc: linux-fsdevel@...r.kernel.org,
Alexander Viro <viro@...iv.linux.org.uk>,
Roland McGrath <roland@...hat.com>,
Oleg Nesterov <oleg@...hat.com>,
Steven Rostedt <rostedt@...dmis.org>,
Cyrill Gorcunov <gorcunov@...nvz.org>,
Pavel Emelyanov <xemul@...allels.com>,
Tejun Heo <tj@...nel.org>
Subject: [PATCH 2/2] ptrace: add ability to attach a file descriptor to another task
Signed-off-by: Andrew Vagin <avagin@...nvz.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists