linux/net/sunrpc/rpc_pipe.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * net/sunrpc/rpc_pipe.c
 *
 * Userland/kernel interface for rpcauth_gss.
 * Code shamelessly plagiarized from fs/nfsd/nfsctl.c
 * and fs/sysfs/inode.c
 *
 * Copyright (c) 2002, Trond Myklebust <[email protected]>
 *
 */
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/pagemap.h>
#include <linux/mount.h>
#include <linux/fs_context.h>
#include <linux/namei.h>
#include <linux/fsnotify.h>
#include <linux/kernel.h>
#include <linux/rcupdate.h>
#include <linux/utsname.h>

#include <asm/ioctls.h>
#include <linux/poll.h>
#include <linux/wait.h>
#include <linux/seq_file.h>

#include <linux/sunrpc/clnt.h>
#include <linux/workqueue.h>
#include <linux/sunrpc/rpc_pipe_fs.h>
#include <linux/sunrpc/cache.h>
#include <linux/nsproxy.h>
#include <linux/notifier.h>

#include "netns.h"
#include "sunrpc.h"

#define RPCDBG_FACILITY

#define NET_NAME(net)

static struct file_system_type rpc_pipe_fs_type;
static const struct rpc_pipe_ops gssd_dummy_pipe_ops;

static struct kmem_cache *rpc_inode_cachep __read_mostly;

#define RPC_UPCALL_TIMEOUT

static BLOCKING_NOTIFIER_HEAD(rpc_pipefs_notifier_list);

int rpc_pipefs_notifier_register(struct notifier_block *nb)
{}
EXPORT_SYMBOL_GPL();

void rpc_pipefs_notifier_unregister(struct notifier_block *nb)
{}
EXPORT_SYMBOL_GPL();

static void rpc_purge_list(wait_queue_head_t *waitq, struct list_head *head,
		void (*destroy_msg)(struct rpc_pipe_msg *), int err)
{}

static void
rpc_timeout_upcall_queue(struct work_struct *work)
{}

ssize_t rpc_pipe_generic_upcall(struct file *filp, struct rpc_pipe_msg *msg,
				char __user *dst, size_t buflen)
{}
EXPORT_SYMBOL_GPL();

/**
 * rpc_queue_upcall - queue an upcall message to userspace
 * @pipe: upcall pipe on which to queue given message
 * @msg: message to queue
 *
 * Call with an @inode created by rpc_mkpipe() to queue an upcall.
 * A userspace process may then later read the upcall by performing a
 * read on an open file for this inode.  It is up to the caller to
 * initialize the fields of @msg (other than @msg->list) appropriately.
 */
int
rpc_queue_upcall(struct rpc_pipe *pipe, struct rpc_pipe_msg *msg)
{}
EXPORT_SYMBOL_GPL();

static inline void
rpc_inode_setowner(struct inode *inode, void *private)
{}

static void
rpc_close_pipes(struct inode *inode)
{}

static struct inode *
rpc_alloc_inode(struct super_block *sb)
{}

static void
rpc_free_inode(struct inode *inode)
{}

static int
rpc_pipe_open(struct inode *inode, struct file *filp)
{}

static int
rpc_pipe_release(struct inode *inode, struct file *filp)
{}

static ssize_t
rpc_pipe_read(struct file *filp, char __user *buf, size_t len, loff_t *offset)
{}

static ssize_t
rpc_pipe_write(struct file *filp, const char __user *buf, size_t len, loff_t *offset)
{}

static __poll_t
rpc_pipe_poll(struct file *filp, struct poll_table_struct *wait)
{}

static long
rpc_pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{}

static const struct file_operations rpc_pipe_fops =;

static int
rpc_show_info(struct seq_file *m, void *v)
{}

static int
rpc_info_open(struct inode *inode, struct file *file)
{}

static int
rpc_info_release(struct inode *inode, struct file *file)
{}

static const struct file_operations rpc_info_operations =;


/*
 * Description of fs contents.
 */
struct rpc_filelist {};

static struct inode *
rpc_get_inode(struct super_block *sb, umode_t mode)
{}

static int __rpc_create_common(struct inode *dir, struct dentry *dentry,
			       umode_t mode,
			       const struct file_operations *i_fop,
			       void *private)
{}

static int __rpc_create(struct inode *dir, struct dentry *dentry,
			umode_t mode,
			const struct file_operations *i_fop,
			void *private)
{}

static int __rpc_mkdir(struct inode *dir, struct dentry *dentry,
		       umode_t mode,
		       const struct file_operations *i_fop,
		       void *private)
{}

static void
init_pipe(struct rpc_pipe *pipe)
{}

void rpc_destroy_pipe_data(struct rpc_pipe *pipe)
{}
EXPORT_SYMBOL_GPL();

struct rpc_pipe *rpc_mkpipe_data(const struct rpc_pipe_ops *ops, int flags)
{}
EXPORT_SYMBOL_GPL();

static int __rpc_mkpipe_dentry(struct inode *dir, struct dentry *dentry,
			       umode_t mode,
			       const struct file_operations *i_fop,
			       void *private,
			       struct rpc_pipe *pipe)
{}

static int __rpc_rmdir(struct inode *dir, struct dentry *dentry)
{}

static int __rpc_unlink(struct inode *dir, struct dentry *dentry)
{}

static int __rpc_rmpipe(struct inode *dir, struct dentry *dentry)
{}

static struct dentry *__rpc_lookup_create_exclusive(struct dentry *parent,
					  const char *name)
{}

/*
 * FIXME: This probably has races.
 */
static void __rpc_depopulate(struct dentry *parent,
			     const struct rpc_filelist *files,
			     int start, int eof)
{}

static void rpc_depopulate(struct dentry *parent,
			   const struct rpc_filelist *files,
			   int start, int eof)
{}

static int rpc_populate(struct dentry *parent,
			const struct rpc_filelist *files,
			int start, int eof,
			void *private)
{}

static struct dentry *rpc_mkdir_populate(struct dentry *parent,
		const char *name, umode_t mode, void *private,
		int (*populate)(struct dentry *, void *), void *args_populate)
{}

static int rpc_rmdir_depopulate(struct dentry *dentry,
		void (*depopulate)(struct dentry *))
{}

/**
 * rpc_mkpipe_dentry - make an rpc_pipefs file for kernel<->userspace
 *		       communication
 * @parent: dentry of directory to create new "pipe" in
 * @name: name of pipe
 * @private: private data to associate with the pipe, for the caller's use
 * @pipe: &rpc_pipe containing input parameters
 *
 * Data is made available for userspace to read by calls to
 * rpc_queue_upcall().  The actual reads will result in calls to
 * @ops->upcall, which will be called with the file pointer,
 * message, and userspace buffer to copy to.
 *
 * Writes can come at any time, and do not necessarily have to be
 * responses to upcalls.  They will result in calls to @msg->downcall.
 *
 * The @private argument passed here will be available to all these methods
 * from the file pointer, via RPC_I(file_inode(file))->private.
 */
struct dentry *rpc_mkpipe_dentry(struct dentry *parent, const char *name,
				 void *private, struct rpc_pipe *pipe)
{}
EXPORT_SYMBOL_GPL();

/**
 * rpc_unlink - remove a pipe
 * @dentry: dentry for the pipe, as returned from rpc_mkpipe
 *
 * After this call, lookups will no longer find the pipe, and any
 * attempts to read or write using preexisting opens of the pipe will
 * return -EPIPE.
 */
int
rpc_unlink(struct dentry *dentry)
{}
EXPORT_SYMBOL_GPL();

/**
 * rpc_init_pipe_dir_head - initialise a struct rpc_pipe_dir_head
 * @pdh: pointer to struct rpc_pipe_dir_head
 */
void rpc_init_pipe_dir_head(struct rpc_pipe_dir_head *pdh)
{}
EXPORT_SYMBOL_GPL();

/**
 * rpc_init_pipe_dir_object - initialise a struct rpc_pipe_dir_object
 * @pdo: pointer to struct rpc_pipe_dir_object
 * @pdo_ops: pointer to const struct rpc_pipe_dir_object_ops
 * @pdo_data: pointer to caller-defined data
 */
void rpc_init_pipe_dir_object(struct rpc_pipe_dir_object *pdo,
		const struct rpc_pipe_dir_object_ops *pdo_ops,
		void *pdo_data)
{}
EXPORT_SYMBOL_GPL();

static int
rpc_add_pipe_dir_object_locked(struct net *net,
		struct rpc_pipe_dir_head *pdh,
		struct rpc_pipe_dir_object *pdo)
{}

static void
rpc_remove_pipe_dir_object_locked(struct net *net,
		struct rpc_pipe_dir_head *pdh,
		struct rpc_pipe_dir_object *pdo)
{}

/**
 * rpc_add_pipe_dir_object - associate a rpc_pipe_dir_object to a directory
 * @net: pointer to struct net
 * @pdh: pointer to struct rpc_pipe_dir_head
 * @pdo: pointer to struct rpc_pipe_dir_object
 *
 */
int
rpc_add_pipe_dir_object(struct net *net,
		struct rpc_pipe_dir_head *pdh,
		struct rpc_pipe_dir_object *pdo)
{}
EXPORT_SYMBOL_GPL();

/**
 * rpc_remove_pipe_dir_object - remove a rpc_pipe_dir_object from a directory
 * @net: pointer to struct net
 * @pdh: pointer to struct rpc_pipe_dir_head
 * @pdo: pointer to struct rpc_pipe_dir_object
 *
 */
void
rpc_remove_pipe_dir_object(struct net *net,
		struct rpc_pipe_dir_head *pdh,
		struct rpc_pipe_dir_object *pdo)
{}
EXPORT_SYMBOL_GPL();

/**
 * rpc_find_or_alloc_pipe_dir_object
 * @net: pointer to struct net
 * @pdh: pointer to struct rpc_pipe_dir_head
 * @match: match struct rpc_pipe_dir_object to data
 * @alloc: allocate a new struct rpc_pipe_dir_object
 * @data: user defined data for match() and alloc()
 *
 */
struct rpc_pipe_dir_object *
rpc_find_or_alloc_pipe_dir_object(struct net *net,
		struct rpc_pipe_dir_head *pdh,
		int (*match)(struct rpc_pipe_dir_object *, void *),
		struct rpc_pipe_dir_object *(*alloc)(void *),
		void *data)
{}
EXPORT_SYMBOL_GPL();

static void
rpc_create_pipe_dir_objects(struct rpc_pipe_dir_head *pdh)
{}

static void
rpc_destroy_pipe_dir_objects(struct rpc_pipe_dir_head *pdh)
{}

enum {};

static const struct rpc_filelist authfiles[] =;

static int rpc_clntdir_populate(struct dentry *dentry, void *private)
{}

static void rpc_clntdir_depopulate(struct dentry *dentry)
{}

/**
 * rpc_create_client_dir - Create a new rpc_client directory in rpc_pipefs
 * @dentry: the parent of new directory
 * @name: the name of new directory
 * @rpc_client: rpc client to associate with this directory
 *
 * This creates a directory at the given @path associated with
 * @rpc_clnt, which will contain a file named "info" with some basic
 * information about the client, together with any "pipes" that may
 * later be created using rpc_mkpipe().
 */
struct dentry *rpc_create_client_dir(struct dentry *dentry,
				   const char *name,
				   struct rpc_clnt *rpc_client)
{}

/**
 * rpc_remove_client_dir - Remove a directory created with rpc_create_client_dir()
 * @rpc_client: rpc_client for the pipe
 */
int rpc_remove_client_dir(struct rpc_clnt *rpc_client)
{}

static const struct rpc_filelist cache_pipefs_files[3] =;

static int rpc_cachedir_populate(struct dentry *dentry, void *private)
{}

static void rpc_cachedir_depopulate(struct dentry *dentry)
{}

struct dentry *rpc_create_cache_dir(struct dentry *parent, const char *name,
				    umode_t umode, struct cache_detail *cd)
{}

void rpc_remove_cache_dir(struct dentry *dentry)
{}

/*
 * populate the filesystem
 */
static const struct super_operations s_ops =;

#define RPCAUTH_GSSMAGIC

/*
 * We have a single directory with 1 node in it.
 */
enum {};

static const struct rpc_filelist files[] =;

/*
 * This call can be used only in RPC pipefs mount notification hooks.
 */
struct dentry *rpc_d_lookup_sb(const struct super_block *sb,
			       const unsigned char *dir_name)
{}
EXPORT_SYMBOL_GPL();

int rpc_pipefs_init_net(struct net *net)
{}

void rpc_pipefs_exit_net(struct net *net)
{}

/*
 * This call will be used for per network namespace operations calls.
 * Note: Function will be returned with pipefs_sb_lock taken if superblock was
 * found. This lock have to be released by rpc_put_sb_net() when all operations
 * will be completed.
 */
struct super_block *rpc_get_sb_net(const struct net *net)
{}
EXPORT_SYMBOL_GPL();

void rpc_put_sb_net(const struct net *net)
{}
EXPORT_SYMBOL_GPL();

static const struct rpc_filelist gssd_dummy_clnt_dir[] =;

static ssize_t
dummy_downcall(struct file *filp, const char __user *src, size_t len)
{}

static const struct rpc_pipe_ops gssd_dummy_pipe_ops =;

/*
 * Here we present a bogus "info" file to keep rpc.gssd happy. We don't expect
 * that it will ever use this info to handle an upcall, but rpc.gssd expects
 * that this file will be there and have a certain format.
 */
static int
rpc_dummy_info_show(struct seq_file *m, void *v)
{}
DEFINE_SHOW_ATTRIBUTE();

static const struct rpc_filelist gssd_dummy_info_file[] =;

/**
 * rpc_gssd_dummy_populate - create a dummy gssd pipe
 * @root:	root of the rpc_pipefs filesystem
 * @pipe_data:	pipe data created when netns is initialized
 *
 * Create a dummy set of directories and a pipe that gssd can hold open to
 * indicate that it is up and running.
 */
static struct dentry *
rpc_gssd_dummy_populate(struct dentry *root, struct rpc_pipe *pipe_data)
{}

static void
rpc_gssd_dummy_depopulate(struct dentry *pipe_dentry)
{}

static int
rpc_fill_super(struct super_block *sb, struct fs_context *fc)
{}

bool
gssd_running(struct net *net)
{}
EXPORT_SYMBOL_GPL();

static int rpc_fs_get_tree(struct fs_context *fc)
{}

static void rpc_fs_free_fc(struct fs_context *fc)
{}

static const struct fs_context_operations rpc_fs_context_ops =;

static int rpc_init_fs_context(struct fs_context *fc)
{}

static void rpc_kill_sb(struct super_block *sb)
{}

static struct file_system_type rpc_pipe_fs_type =;
MODULE_ALIAS_FS();
MODULE_ALIAS();

static void
init_once(void *foo)
{}

int register_rpc_pipefs(void)
{}

void unregister_rpc_pipefs(void)
{}