lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1324032383-791758-2-git-send-email-avagin@openvz.org>
Date:	Fri, 16 Dec 2011 13:46:22 +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 1/2] fs: add ability to attach and to allocate fd for non current tasks


Signed-off-by: Andrew Vagin <avagin@...nvz.org>
---
 fs/file.c            |    9 +++++++--
 fs/open.c            |    9 +++++++--
 include/linux/file.h |    4 ++++
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/fs/file.c b/fs/file.c
index 4c6992d..fbf2879 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -428,9 +428,9 @@ struct files_struct init_files = {
 /*
  * allocate a file descriptor, mark it busy.
  */
-int alloc_fd(unsigned start, unsigned flags)
+int alloc_task_fd(struct task_struct *tsk, unsigned start, unsigned flags)
 {
-	struct files_struct *files = current->files;
+	struct files_struct *files = tsk->files;
 	unsigned int fd;
 	int error;
 	struct fdtable *fdt;
@@ -479,6 +479,11 @@ out:
 	return error;
 }
 
+int alloc_fd(unsigned start, unsigned flags)
+{
+	return alloc_task_fd(current, start, flags);
+}
+
 int get_unused_fd(void)
 {
 	return alloc_fd(0, 0);
diff --git a/fs/open.c b/fs/open.c
index 22c41b5..9d340cc 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -864,9 +864,9 @@ EXPORT_SYMBOL(put_unused_fd);
  * will follow.
  */
 
-void fd_install(unsigned int fd, struct file *file)
+void fd_task_install(struct task_struct *tsk, unsigned int fd, struct file *file)
 {
-	struct files_struct *files = current->files;
+	struct files_struct *files = tsk->files;
 	struct fdtable *fdt;
 	spin_lock(&files->file_lock);
 	fdt = files_fdtable(files);
@@ -875,6 +875,11 @@ void fd_install(unsigned int fd, struct file *file)
 	spin_unlock(&files->file_lock);
 }
 
+void fd_install(unsigned int fd, struct file *file)
+{
+	return fd_task_install(current, fd, file);
+}
+
 EXPORT_SYMBOL(fd_install);
 
 static inline int build_open_flags(int flags, int mode, struct open_flags *op)
diff --git a/include/linux/file.h b/include/linux/file.h
index 21a7995..0250cf4 100644
--- a/include/linux/file.h
+++ b/include/linux/file.h
@@ -34,10 +34,14 @@ extern struct file *fget_raw_light(unsigned int fd, int *fput_needed);
 extern void set_close_on_exec(unsigned int fd, int flag);
 extern void put_filp(struct file *);
 extern int alloc_fd(unsigned start, unsigned flags);
+struct task_struct;
+extern int alloc_task_fd(struct task_struct *tsk, unsigned start, unsigned flags);
 extern int get_unused_fd(void);
 #define get_unused_fd_flags(flags) alloc_fd(0, (flags))
 extern void put_unused_fd(unsigned int fd);
 
+extern void fd_task_install(struct task_struct *tsk,
+				unsigned int fd, struct file *file);
 extern void fd_install(unsigned int fd, struct file *file);
 
 #endif /* __LINUX_FILE_H */
-- 
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ