• Davide Libenzi's avatar
    Split the anonfd interface into a bare file pointer creation one, and a · 4b23c37a
    Davide Libenzi authored
    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: default avatarDavide Libenzi <davidel@xmailserver.org>
    Cc: Alexander Viro <viro@zeniv.linux.org.uk>
    Cc: James Morris <jmorris@namei.org>
    Cc: Serge Hallyn <serue@us.ibm.com>
    Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
    Cc: Gregory Haskins <ghaskins@novell.com>
    Acked-by: default avatarRoland Dreier <rolandd@cisco.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    4b23c37a
eventfd.h 1.61 KB