diff options
author | Davide Libenzi <davidel@xmailserver.org> | 2009-09-22 16:43:57 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-23 07:39:29 -0700 |
commit | 562787a5c32ccdf182de27793a83a9f2ee86cd77 (patch) | |
tree | 3308afd59d3b7449afa3d6a6cd624d06ce035e88 /include/linux/anon_inodes.h | |
parent | 515350b6fd041396f425180589e08812dd13615f (diff) | |
download | op-kernel-dev-562787a5c32ccdf182de27793a83a9f2ee86cd77.zip op-kernel-dev-562787a5c32ccdf182de27793a83a9f2ee86cd77.tar.gz |
anonfd: split interface into file creation and install
Split the anonfd interface into a bare file pointer creation one, and a
file pointer creation plus install one.
There are cases, like the usage of eventfds inside other kernel
interfaces, where the file pointer created by anonfd needs to be used
inside the initialization of other structures.
As it is right now, as soon as anon_inode_getfd() returns, the kenrle can
race with userspace closing the newly installed file descriptor.
This patch, while keeping the old anon_inode_getfd(), introduces a new
anon_inode_getfile() (whose services are reused in anon_inode_getfd())
that allows to split the file creation phase and the fd install one.
Once all the kernel structures are initialized, the code can call the
proper fd_install().
Gregory manifested the need for something like this inside KVM.
Signed-off-by: Davide Libenzi <davidel@xmailserver.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: James Morris <jmorris@namei.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Gregory Haskins <ghaskins@novell.com>
Acked-by: Serge Hallyn <serue@us.ibm.com>
Acked-by: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/anon_inodes.h')
-rw-r--r-- | include/linux/anon_inodes.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/include/linux/anon_inodes.h b/include/linux/anon_inodes.h index e0a0cdc..69a21e0 100644 --- a/include/linux/anon_inodes.h +++ b/include/linux/anon_inodes.h @@ -8,6 +8,9 @@ #ifndef _LINUX_ANON_INODES_H #define _LINUX_ANON_INODES_H +struct file *anon_inode_getfile(const char *name, + const struct file_operations *fops, + void *priv, int flags); int anon_inode_getfd(const char *name, const struct file_operations *fops, void *priv, int flags); |