linux/kernel/bpf/inode.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Minimal file system backend for holding eBPF maps and programs,
 * used by bpf(2) object pinning.
 *
 * Authors:
 *
 *	Daniel Borkmann <[email protected]>
 */

#include <linux/init.h>
#include <linux/magic.h>
#include <linux/major.h>
#include <linux/mount.h>
#include <linux/namei.h>
#include <linux/fs.h>
#include <linux/fs_context.h>
#include <linux/fs_parser.h>
#include <linux/kdev_t.h>
#include <linux/filter.h>
#include <linux/bpf.h>
#include <linux/bpf_trace.h>
#include <linux/kstrtox.h>
#include "preload/bpf_preload.h"

enum bpf_type {};

static void *bpf_any_get(void *raw, enum bpf_type type)
{}

static void bpf_any_put(void *raw, enum bpf_type type)
{}

static void *bpf_fd_probe_obj(u32 ufd, enum bpf_type *type)
{}

static const struct inode_operations bpf_dir_iops;

static const struct inode_operations bpf_prog_iops =;
static const struct inode_operations bpf_map_iops  =;
static const struct inode_operations bpf_link_iops  =;

struct inode *bpf_get_inode(struct super_block *sb,
			    const struct inode *dir,
			    umode_t mode)
{}

static int bpf_inode_type(const struct inode *inode, enum bpf_type *type)
{}

static void bpf_dentry_finalize(struct dentry *dentry, struct inode *inode,
				struct inode *dir)
{}

static int bpf_mkdir(struct mnt_idmap *idmap, struct inode *dir,
		     struct dentry *dentry, umode_t mode)
{}

struct map_iter {};

static struct map_iter *map_iter(struct seq_file *m)
{}

static struct bpf_map *seq_file_to_map(struct seq_file *m)
{}

static void map_iter_free(struct map_iter *iter)
{}

static struct map_iter *map_iter_alloc(struct bpf_map *map)
{}

static void *map_seq_next(struct seq_file *m, void *v, loff_t *pos)
{}

static void *map_seq_start(struct seq_file *m, loff_t *pos)
{}

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

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

static const struct seq_operations bpffs_map_seq_ops =;

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

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

/* bpffs_map_fops should only implement the basic
 * read operation for a BPF map.  The purpose is to
 * provide a simple user intuitive way to do
 * "cat bpffs/pathto/a-pinned-map".
 *
 * Other operations (e.g. write, lookup...) should be realized by
 * the userspace tools (e.g. bpftool) through the
 * BPF_OBJ_GET_INFO_BY_FD and the map's lookup/update
 * interface.
 */
static const struct file_operations bpffs_map_fops =;

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

static const struct file_operations bpffs_obj_fops =;

static int bpf_mkobj_ops(struct dentry *dentry, umode_t mode, void *raw,
			 const struct inode_operations *iops,
			 const struct file_operations *fops)
{}

static int bpf_mkprog(struct dentry *dentry, umode_t mode, void *arg)
{}

static int bpf_mkmap(struct dentry *dentry, umode_t mode, void *arg)
{}

static int bpf_mklink(struct dentry *dentry, umode_t mode, void *arg)
{}

static struct dentry *
bpf_lookup(struct inode *dir, struct dentry *dentry, unsigned flags)
{}

static int bpf_symlink(struct mnt_idmap *idmap, struct inode *dir,
		       struct dentry *dentry, const char *target)
{}

static const struct inode_operations bpf_dir_iops =;

/* pin iterator link into bpffs */
static int bpf_iter_link_pin_kernel(struct dentry *parent,
				    const char *name, struct bpf_link *link)
{}

static int bpf_obj_do_pin(int path_fd, const char __user *pathname, void *raw,
			  enum bpf_type type)
{}

int bpf_obj_pin_user(u32 ufd, int path_fd, const char __user *pathname)
{}

static void *bpf_obj_do_get(int path_fd, const char __user *pathname,
			    enum bpf_type *type, int flags)
{}

int bpf_obj_get_user(int path_fd, const char __user *pathname, int flags)
{}

static struct bpf_prog *__get_prog_inode(struct inode *inode, enum bpf_prog_type type)
{}

struct bpf_prog *bpf_prog_get_type_path(const char *name, enum bpf_prog_type type)
{}
EXPORT_SYMBOL();

struct bpffs_btf_enums {};

static int find_bpffs_btf_enums(struct bpffs_btf_enums *info)
{}

static bool find_btf_enum_const(const struct btf *btf, const struct btf_type *enum_t,
				const char *prefix, const char *str, int *value)
{}

static void seq_print_delegate_opts(struct seq_file *m,
				    const char *opt_name,
				    const struct btf *btf,
				    const struct btf_type *enum_t,
				    const char *prefix,
				    u64 delegate_msk, u64 any_msk)
{}

/*
 * Display the mount options in /proc/mounts.
 */
static int bpf_show_options(struct seq_file *m, struct dentry *root)
{}

static void bpf_free_inode(struct inode *inode)
{}

const struct super_operations bpf_super_ops =;

enum {};

static const struct fs_parameter_spec bpf_fs_parameters[] =;

static int bpf_parse_param(struct fs_context *fc, struct fs_parameter *param)
{}

struct bpf_preload_ops *bpf_preload_ops;
EXPORT_SYMBOL_GPL();

static bool bpf_preload_mod_get(void)
{}

static void bpf_preload_mod_put(void)
{}

static DEFINE_MUTEX(bpf_preload_lock);

static int populate_bpffs(struct dentry *parent)
{}

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

static int bpf_get_tree(struct fs_context *fc)
{}

static void bpf_free_fc(struct fs_context *fc)
{}

static const struct fs_context_operations bpf_context_ops =;

/*
 * Set up the filesystem mount context.
 */
static int bpf_init_fs_context(struct fs_context *fc)
{}

static void bpf_kill_super(struct super_block *sb)
{}

static struct file_system_type bpf_fs_type =;

static int __init bpf_init(void)
{}
fs_initcall(bpf_init);