linux/lib/error-inject.c

// SPDX-License-Identifier: GPL-2.0
// error-inject.c: Function-level error injection table
#include <linux/error-injection.h>
#include <linux/debugfs.h>
#include <linux/kallsyms.h>
#include <linux/kprobes.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/list.h>
#include <linux/slab.h>
#include <asm/sections.h>

/* Whitelist of symbols that can be overridden for error injection. */
static LIST_HEAD(error_injection_list);
static DEFINE_MUTEX(ei_mutex);
struct ei_entry {};

bool within_error_injection_list(unsigned long addr)
{}

int get_injectable_error_type(unsigned long addr)
{}

/*
 * Lookup and populate the error_injection_list.
 *
 * For safety reasons we only allow certain functions to be overridden with
 * bpf_error_injection, so we need to populate the list of the symbols that have
 * been marked as safe for overriding.
 */
static void populate_error_injection_list(struct error_injection_entry *start,
					  struct error_injection_entry *end,
					  void *priv)
{}

/* Markers of the _error_inject_whitelist section */
extern struct error_injection_entry __start_error_injection_whitelist[];
extern struct error_injection_entry __stop_error_injection_whitelist[];

static void __init populate_kernel_ei_list(void)
{}

#ifdef CONFIG_MODULES
static void module_load_ei_list(struct module *mod)
{}

static void module_unload_ei_list(struct module *mod)
{}

/* Module notifier call back, checking error injection table on the module */
static int ei_module_callback(struct notifier_block *nb,
			      unsigned long val, void *data)
{}

static struct notifier_block ei_module_nb =;

static __init int module_ei_init(void)
{}
#else /* !CONFIG_MODULES */
#define module_ei_init
#endif

/*
 * error_injection/whitelist -- shows which functions can be overridden for
 * error injection.
 */
static void *ei_seq_start(struct seq_file *m, loff_t *pos)
{}

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

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

static const char *error_type_string(int etype)
{}

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

static const struct seq_operations ei_sops =;

DEFINE_SEQ_ATTRIBUTE();

static int __init ei_debugfs_init(void)
{}

static int __init init_error_injection(void)
{}
late_initcall(init_error_injection);